Skip to content

Commit

Permalink
feat: add home-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
gametaro committed Jan 24, 2024
1 parent 3e62bc5 commit cf69a49
Show file tree
Hide file tree
Showing 9 changed files with 1,151 additions and 0 deletions.
760 changes: 760 additions & 0 deletions home/dot_config/home-manager/flake.lock

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions home/dot_config/home-manager/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
description = "Home Manager configuration";

inputs = {
# Specify the source of Home Manager and Nixpkgs.
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
devshell = {
url = "github:numtide/devshell";
inputs.nixpkgs.follows = "nixpkgs";
};
pre-commit-hooks-nix = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
neovim = {
url = "github:gametaro/neovim-flake";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = {flake-parts, ...} @ inputs:
flake-parts.lib.mkFlake {inherit inputs;} {
debug = true;
imports = [
inputs.pre-commit-hooks-nix.flakeModule
inputs.devshell.flakeModule
./parts
];
systems = [
# "aarch64-darwin"
"aarch64-linux"
# "x86_64-darwin"
"x86_64-linux"
];
};
}
75 changes: 75 additions & 0 deletions home/dot_config/home-manager/home.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{ config, pkgs, ... }:

{
# Home Manager needs a bit of information about you and the paths it should
# manage.
home.username = "ky";
home.homeDirectory = "/home/ky";

# This value determines the Home Manager release that your configuration is
# compatible with. This helps avoid breakage when a new Home Manager release
# introduces backwards incompatible changes.
#
# You should not change this value, even if you update Home Manager. If you do
# want to update the value, then make sure to first check the Home Manager
# release notes.
home.stateVersion = "23.11"; # Please read the comment before changing.

# The home.packages option allows you to install Nix packages into your
# environment.
home.packages = [
# # Adds the 'hello' command to your environment. It prints a friendly
# # "Hello, world!" when run.
# pkgs.hello

# # It is sometimes useful to fine-tune packages, for example, by applying
# # overrides. You can do that directly here, just don't forget the
# # parentheses. Maybe you want to install Nerd Fonts with a limited number of
# # fonts?
# (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; })

# # You can also create simple shell scripts directly inside your
# # configuration. For example, this adds a command 'my-hello' to your
# # environment:
# (pkgs.writeShellScriptBin "my-hello" ''
# echo "Hello, ${config.home.username}!"
# '')
];

# Home Manager is pretty good at managing dotfiles. The primary way to manage
# plain files is through 'home.file'.
home.file = {
# # Building this configuration will create a copy of 'dotfiles/screenrc' in
# # the Nix store. Activating the configuration will then make '~/.screenrc' a
# # symlink to the Nix store copy.
# ".screenrc".source = dotfiles/screenrc;

# # You can also set the file content immediately.
# ".gradle/gradle.properties".text = ''
# org.gradle.console=verbose
# org.gradle.daemon.idletimeout=3600000
# '';
};

# Home Manager can also manage your environment variables through
# 'home.sessionVariables'. If you don't want to manage your shell through Home
# Manager then you have to manually source 'hm-session-vars.sh' located at
# either
#
# ~/.nix-profile/etc/profile.d/hm-session-vars.sh
#
# or
#
# ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh
#
# or
#
# /etc/profiles/per-user/ky/etc/profile.d/hm-session-vars.sh
#
home.sessionVariables = {
# EDITOR = "emacs";
};

# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
}
13 changes: 13 additions & 0 deletions home/dot_config/home-manager/parts/checks.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
perSystem = _: {
pre-commit = {
settings = {
hooks = {
alejandra.enable = true;
nil.enable = true;
statix.enable = true;
};
};
};
};
}
8 changes: 8 additions & 0 deletions home/dot_config/home-manager/parts/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
_: {
imports = [
./checks.nix
./devshell.nix
./packages.nix
./home-manager.nix
];
}
11 changes: 11 additions & 0 deletions home/dot_config/home-manager/parts/devshell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
perSystem = {pkgs, ...}: {
devshells.default = {
packages = with pkgs; [
alejandra
nil
statix
];
};
};
}
13 changes: 13 additions & 0 deletions home/dot_config/home-manager/parts/home-manager.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{inputs, ...}: {
perSystem = {
inputs',
pkgs,
...
}: {
legacyPackages.homeConfigurations.gametaro = inputs.home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [./home.nix];
# extraSpecialArgs = {};
};
};
}
215 changes: 215 additions & 0 deletions home/dot_config/home-manager/parts/home.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
{
config,
pkgs,
...
}: {
home = {
username = "gametaro";
homeDirectory = "/home/gametaro";
stateVersion = "23.11";

packages = with pkgs; [
curl
fd
];

file = {};

sessionVariables = {
EDITOR = "nvim";
VISUAL = "${config.home.sessionVariables.EDITOR}";
SUDO_EDITOR = "${config.home.sessionVariables.EDITOR}";
MANPAGER = "nvim +Man!";
};

shellAliases = {
g = "git";
v = "nvim";
};
};
programs = {
home-manager.enable = true;
ssh.enable = true;
bash = {
enable = true;
enableVteIntegration = true;
historyControl = ["erasedups" "ignoredups" "ignorespace"];
# bashrcExtra = {};
shellAliases = {
".." = "cd ..";
grep = "grep --color=auto";
ls = "ls --color=auto";
l = "ls -CF";
la = "ls -A";
ll = "ls -alF";
};
};
fish = {
enable = true;
shellInit = ''
set fish_greeting
'';
shellAbbrs = {
v = "nvim";
g = "git";
ga = "git add";
gaa = "git add --all";
gau = "git add --update";
gb = "git branch";
gc = "git commit";
gca = "git commit --amend";
gcam = "git commit --amend --message";
gcane = "git commit --amend --no-edit";
gco = "git checkout";
gd = "git diff";
gdc = "git diff --cached";
gf = "git fetch";
gfa = "git fetch --all";
gg = "git grep";
ggg = "git grep-group";
gl = "git log";
glg = "git log --graph";
gll = "git log-list";
glo = "git log --oneline";
glp = "git log --patch";
gls = "git ls-files";
gm = "git merge";
gma = "git merge --abort";
gmc = "git merge --continue";
gp = "git pull";
gpf = "git pull --ff-only";
gpr = "git pull --rebase";
grb = "git rebase";
gs = "git status";
gss = "git status --short";
};
};
direnv = {
enable = true;
nix-direnv.enable = true;
};
readline = {
enable = true;
variables = {
colored-completion-prefix = true;
colored-stats = true;
completion-ignore-case = true;
completion-map-case = true;
mark-modified-lines = true;
visible-stats = true;
};
};
ripgrep = {
enable = true;
arguments = [
"--smart-case"
"--hidden"
"--glob=!.git/*"
];
};
gh = {
enable = true;
settings = {
git_protocol = "https";
prompt = "enabled";
aliases = {
co = "pr checkout";
s = "status";
};
};
};
git = {
enable = true;
userName = "Kotaro Yamada";
userEmail = "[email protected]";
signing = {
key = null;
signByDefault = true;
};
aliases = {
a = "add";
b = "branch";
c = "commit";
d = "diff";
f = "fetch";
g = "grep";
l = "log";
m = "merge";
o = "checkout";
p = "pull";
s = "status";
w = "whatchanged";

aa = "add --all";
au = "add --update";
bm = "branch --merged";
ca = "commit --amend";
cam = "commit --amend --message";
cane = "commit --amend --no-edit";
co = "checkout";
cm = "commit --message";
cp = "cherry-pick";
dc = "diff --cached";
ds = "diff --staged";
dw = "diff --word-diff";
dd = "diff-deep";
fa = "fetch --all";
gg = "grep --break --heading --line-number --color";
lg = "log --graph";
lo = "log --oneline";
lp = "log --patch";
ll = "log-list";
lll = "log-list-long";
ls = "git ls-files";
ma = "merge --abort";
mc = "merge --continue";
rb = "rebase";
rba = "rebase --abort";
rbc = "rebase --continue";
rbs = "rebase --skip";
rbi = "rebase --interactive";
rl = "reflog";
rr = "remote";
ss = "status --short";

uncommit = "reset --soft HEAD~1";
unadd = "reset HEAD";
discard = "checkout --";
cleaner = "clean -dff";
cleanest = "clean -dffx";
pushy = "!git push --force-with-lease";
};
difftastic.enable = true;
extraConfig = {
init = {defaultBranch = "main";};
branch = {autoSetupRebase = "always";};
commit = {verbose = true;};
diff = {renames = "copy";};
fetch = {
prune = true;
writeCommitGraph = true;
};
merge = {conflictStyle = "zdiff3";};
mergetool = {keepBackup = false;};
pull = {rebase = true;};
push = {
autoSetupRemote = true;
followTags = true;
};
rebase = {
autoSquash = true;
autoStash = true;
stat = true;
updateRefs = true;
};
rerere = {
autoUpdate = true;
enabled = true;
};
status = {showUntrackedFiles = "all";};
};
};
starship.enable = true;
zoxide.enable = true;
};
}
12 changes: 12 additions & 0 deletions home/dot_config/home-manager/parts/packages.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
perSystem = {
config,
inputs',
...
}: {
packages = {
inherit (inputs'.neovim.packages) nvim;
default = config.packages.nvim;
};
};
}

0 comments on commit cf69a49

Please sign in to comment.