diff --git a/modules/home-manager.nix b/modules/home-manager.nix deleted file mode 100644 index f226ca1..0000000 --- a/modules/home-manager.nix +++ /dev/null @@ -1,105 +0,0 @@ -{ stateVersion }: -let - gitconfigs = - (builtins.filterSource (path: type: type != "directory") ./gitconfigs); - gitconfigFiles = builtins.attrNames (builtins.readDir gitconfigs); - makeCommonGitConfigs = { extraGitConfigs ? [ ] }: { - delta = { enable = true; }; - extraConfig = { - color = { ui = "auto"; }; - push = { - default = "upstream"; - autoSetupRemote = true; - }; - init = { defaultBranch = "main"; }; - }; - includes = - (builtins.map (f: { path = gitconfigs + "/" + f; }) gitconfigFiles) - ++ extraGitConfigs; - }; - commonProgramsConfig = { pkgs }: { - bat.enable = true; - neovim = { - enable = true; - defaultEditor = true; - viAlias = true; - vimAlias = true; - }; - direnv.enable = true; - lsd = { - enable = true; - enableAliases = true; - }; - zsh = { - enable = true; - autosuggestion.enable = true; - initExtra = '' - export PROMPT='%(!.%{%F{yellow}%}.)$USER@%{$fg[white]%}%M %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)' - ''; - }; - zsh.oh-my-zsh = { - enable = true; - plugins = [ "git" "sudo" ]; - theme = "robbyrussell"; - }; - tmux = { - enable = true; - clock24 = true; - mouse = true; - plugins = with pkgs.tmuxPlugins; [ nord cpu battery sidebar ]; - }; - }; -in -{ - makeRootUser = { pkgs, ... }: { - home = { - stateVersion = stateVersion; - shellAliases = { - cat = "bat"; - }; - }; - programs = { - git = { - enable = true; - userName = "root"; - } // (makeCommonGitConfigs { extraGitConfigs = [ ]; }); - } // (commonProgramsConfig { pkgs = pkgs; }); - }; - - makeCommonUser = - { enableDevelopmentKit ? false - , fullName - , email - , extraGitConfigs ? [ ] - , name - , homeDirectory ? null - , ... - }: { pkgs, ... }: { - home = { - username = name; - homeDirectory = if (builtins.isNull homeDirectory) then "/home/${name}" else homeDirectory; - stateVersion = stateVersion; - shellAliases = { - cat = "bat"; - }; - packages = with pkgs; - [ jq nixpkgs-fmt ipfetch nixd ] - ++ (if enableDevelopmentKit then [ - rye - devenv - uv - devbox - terraform - kubectl - ] else - [ ]); - }; - programs = { - git = { - enable = true; - userName = fullName; - userEmail = email; - } // (makeCommonGitConfigs { extraGitConfigs = extraGitConfigs; }); - } // (commonProgramsConfig { pkgs = pkgs; }); - }; -} diff --git a/modules/home/default.nix b/modules/home/default.nix new file mode 100644 index 0000000..d8f142f --- /dev/null +++ b/modules/home/default.nix @@ -0,0 +1,55 @@ +{ stateVersion }: +let + makeCommonGitConfigs = (import ./git).makeCommonGitConfigs; + programsModule = (import ./programs); + servicesModule = (import ./services); + homeModule = { + stateVersion = stateVersion; + shellAliases = { + cat = "bat"; + }; + }; +in +{ + makeRootUser = { hostName }: { pkgs, ... }: { + home = homeModule; + programs = (programsModule { pkgs = pkgs; }) // { + git = (makeCommonGitConfigs { + userName = "root"; + userEmail = "root@${hostName}"; + extraGitConfigs = [ ]; + }); + }; + services = servicesModule { pkgs = pkgs; }; + }; + + makeCommonUser = + { enableDevelopmentKit + , fullName + , email + , extraGitConfigs ? [ ] + , ... + }: { pkgs, ... }: { + home = homeModule // { + packages = with pkgs; + [ jq nixpkgs-fmt ipfetch nixd ] + ++ (if enableDevelopmentKit then [ + rye + devenv + uv + devbox + terraform + kubectl + ] else + [ ]); + }; + programs = (programsModule { pkgs = pkgs; }) // { + git = (makeCommonGitConfigs { + userName = fullName; + userEmail = email; + extraGitConfigs = extraGitConfigs; + }); + }; + services = servicesModule { pkgs = pkgs; }; + }; +} diff --git a/modules/home/git.nix b/modules/home/git.nix new file mode 100644 index 0000000..23b6731 --- /dev/null +++ b/modules/home/git.nix @@ -0,0 +1,29 @@ +let + gitconfigs = + (builtins.filterSource (path: type: type != "directory") ./gitconfigs); + gitconfigFiles = builtins.attrNames (builtins.readDir gitconfigs); + makeCommonGitConfigs = + { userName + , userEmail + , extraGitConfigs ? [ ] + }: { + enable = true; + userName = userName; + userEmail = userEmail; + delta = { enable = true; }; + extraConfig = { + color = { ui = "auto"; }; + push = { + default = "upstream"; + autoSetupRemote = true; + }; + init = { defaultBranch = "main"; }; + }; + includes = + (builtins.map (f: { path = gitconfigs + "/" + f; }) gitconfigFiles) + ++ extraGitConfigs; + }; +in +{ + makeCommonGitConfigs = makeCommonGitConfigs; +} diff --git a/modules/gitconfigs/alias.conf b/modules/home/gitconfigs/alias.conf similarity index 100% rename from modules/gitconfigs/alias.conf rename to modules/home/gitconfigs/alias.conf diff --git a/modules/home/programs.nix b/modules/home/programs.nix new file mode 100644 index 0000000..4a48e75 --- /dev/null +++ b/modules/home/programs.nix @@ -0,0 +1,33 @@ +{ pkgs, ... }: +{ + bat.enable = true; + neovim = { + enable = true; + defaultEditor = true; + viAlias = true; + vimAlias = true; + }; + direnv.enable = true; + lsd = { + enable = true; + enableAliases = true; + }; + zsh = { + enable = true; + autosuggestion.enable = true; + initExtra = '' + export PROMPT='%(!.%{%F{yellow}%}.)$USER@%{$fg[white]%}%M %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)' + ''; + oh-my-zsh = { + enable = true; + plugins = [ "git" "sudo" ]; + theme = "robbyrussell"; + }; + }; + tmux = { + enable = true; + clock24 = true; + mouse = true; + plugins = with pkgs.tmuxPlugins; [ nord cpu battery sidebar ]; + }; +} diff --git a/modules/home/services.nix b/modules/home/services.nix new file mode 100644 index 0000000..6a03bed --- /dev/null +++ b/modules/home/services.nix @@ -0,0 +1,8 @@ +{ pkgs, ... }: +{ + gpg-agent = { + enable = true; + defaultCacheTtl = 1800; + enableSshSupport = true; + }; +} diff --git a/modules/lib.nix b/modules/lib.nix index 8aa92c0..d304376 100644 --- a/modules/lib.nix +++ b/modules/lib.nix @@ -66,7 +66,7 @@ let , system ? "x86_64-linux" }: let - hm = (import ./home-manager.nix { + hm = (import ./home { stateVersion = homeManagerVersion; }); pkgs = allPkgs."${system}"; diff --git a/modules/skyg/user.nix b/modules/skyg/user.nix index 897e982..f822ff5 100644 --- a/modules/skyg/user.nix +++ b/modules/skyg/user.nix @@ -38,7 +38,7 @@ in config = let - hm = (import ../home-manager.nix { + hm = (import ../home { stateVersion = cfg.home-manager.version; }); in