diff --git a/flake.nix b/flake.nix index 526deec..05fe2e9 100644 --- a/flake.nix +++ b/flake.nix @@ -132,6 +132,12 @@ (import ./hosts/asosnovsky-mac.nix { user = sumoUser; }); }; + # None-NIXOS LINUX Setups + # ------------- + homeConfigurations."${user.name}" = lib.makeHomeManagerUsers { + user = user; + homeManagerVersion = homeManagerVersion; + }; nixosConfigurations = { # NIXOS Framework Setups diff --git a/hosts/fwbook.nix b/hosts/fwbook.nix index 41d57bd..43f1252 100644 --- a/hosts/fwbook.nix +++ b/hosts/fwbook.nix @@ -1,11 +1,12 @@ { user, dataDir ? "/mnt/Data", unstable }: { pkgs, lib, config, ... }: let - zshFWBook = builtins.filterSource (p: t: true) ../configs/fwbook; + zshFWBook = builtins.filterSource (p: t: true) ./scripts/fwbook; zshFunctions = zshFWBook + "/functions.sh"; in { imports = [ ./fwbook.hardware-configuration.nix ]; + skyg.user.enabled = true; services.fwupd.enable = true; services.fwupd.package = (import (builtins.fetchTarball { diff --git a/hosts/hl-bigbox1.nix b/hosts/hl-bigbox1.nix index f6b23d5..57dbbf9 100644 --- a/hosts/hl-bigbox1.nix +++ b/hosts/hl-bigbox1.nix @@ -1,6 +1,7 @@ { user }: { pkgs, lib, config, ... }: { imports = [ ./hl-bigbox1.hardware-configuration.nix ]; + skyg.user.enabled = true; # firmware updater services.fwupd.enable = true; virtualisation.docker.enableNvidia = true; @@ -75,6 +76,6 @@ steam-tui steam-run steamPackages.steamcmd - ollama - ]; + ollama + ]; } diff --git a/hosts/hl-fws1.nix b/hosts/hl-fws1.nix index 695bd4a..bbc3787 100644 --- a/hosts/hl-fws1.nix +++ b/hosts/hl-fws1.nix @@ -1,6 +1,7 @@ { user }: { pkgs, lib, config, ... }: { imports = [ ./hl-minipc1.hardware-configuration.nix ]; + skyg.user.enabled = true; # firmware updater services.fwupd.enable = true; diff --git a/hosts/hl-minipc1.nix b/hosts/hl-minipc1.nix index 9ee8186..30be545 100644 --- a/hosts/hl-minipc1.nix +++ b/hosts/hl-minipc1.nix @@ -1,6 +1,8 @@ { user }: { pkgs, lib, config, ... }: { imports = [ ./hl-minipc1.hardware-configuration.nix ]; + skyg.user.enabled = true; + # Nix Stores services.nix-serve = { enable = true; diff --git a/hosts/hl-minipc2.nix b/hosts/hl-minipc2.nix index d47b33b..0a17591 100644 --- a/hosts/hl-minipc2.nix +++ b/hosts/hl-minipc2.nix @@ -1,6 +1,7 @@ { user }: { pkgs, lib, config, ... }: { imports = [ ./hl-minipc2.hardware-configuration.nix ]; + skyg.user.enabled = true; # firmware updater services.fwupd.enable = true; # Bootloader. diff --git a/hosts/hl-terra1.nix b/hosts/hl-terra1.nix index 5d7926d..43275ef 100644 --- a/hosts/hl-terra1.nix +++ b/hosts/hl-terra1.nix @@ -2,6 +2,7 @@ { pkgs, lib, config, ... }: { imports = [ ./hl-terra1.hardware-configuration.nix ]; + skyg.user.enabled = true; # firmware updater services.fwupd.enable = true; # Bootloader. diff --git a/configs/fwbook/functions.sh b/hosts/scripts/fwbook/functions.sh similarity index 100% rename from configs/fwbook/functions.sh rename to hosts/scripts/fwbook/functions.sh diff --git a/modules/home/default.nix b/modules/home/default.nix new file mode 100644 index 0000000..365e6b4 --- /dev/null +++ b/modules/home/default.nix @@ -0,0 +1,58 @@ +{ stateVersion }: +let + makeCommonGitConfigs = (import ./git.nix).makeCommonGitConfigs; + programsModule = (import ./programs.nix); + servicesModule = (import ./services.nix); + 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 ? false + , fullName + , email + , extraGitConfigs ? [ ] + , name + , ... + }: { pkgs, ... }: { + home = homeModule // { + username = name; + homeDirectory = "/home/${name}"; + 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/skyg/gitconfigs/alias.conf b/modules/home/gitconfigs/alias.conf similarity index 100% rename from modules/skyg/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 48926b4..d304376 100644 --- a/modules/lib.nix +++ b/modules/lib.nix @@ -14,7 +14,7 @@ let (import ./main.nix attrs) ] ++ extraConfiguration; eachSystem = nixpkgs.lib.genAttrs (import systems); - pkgs = eachSystem (system: + allPkgs = eachSystem (system: import nixpkgs { system = system; config = { allowUnfree = true; }; @@ -59,13 +59,32 @@ let }) ]; }; + makeHomeManagerUsers = + { modules ? [ ] + , homeManagerVersion + , user + , system ? "x86_64-linux" + }: + let + hm = (import ./home { + stateVersion = homeManagerVersion; + }); + pkgs = allPkgs."${system}"; + in + home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = [ + (hm.makeCommonUser user) + ] ++ modules; + }; in { eachSystem = eachSystem; - pkgs = pkgs; + pkgs = allPkgs; makeNixOsModule = makeNixOsModule; makeHLService = makeHLService; makeDarwinModule = makeDarwinModule; + makeHomeManagerUsers = makeHomeManagerUsers; makeHLServices = { nodeNames ? [ ] , systemStateVersion ? "24.05" diff --git a/modules/os/default.nix b/modules/os/default.nix index b7b034c..1607245 100644 --- a/modules/os/default.nix +++ b/modules/os/default.nix @@ -12,7 +12,6 @@ { pkgs, ... }: { imports = [ (import ./core.nix { user = user; }) - ./rootUser.nix (import ./user.nix { user = user; }) (import ./containers/default.nix ({ user = user; diff --git a/modules/os/rootUser.nix b/modules/os/rootUser.nix deleted file mode 100644 index 7cab540..0000000 --- a/modules/os/rootUser.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ pkgs, ... }: -{ - users.users.root.shell = pkgs.zsh; -} diff --git a/modules/skyg/core.nix b/modules/skyg/core.nix index 558cfd6..f6ccef7 100644 --- a/modules/skyg/core.nix +++ b/modules/skyg/core.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ config, lib, pkgs, ... }: with lib; @@ -16,7 +16,7 @@ in }; config = { - home-manager.users.root.programs.git.userEmail = "root@${cfg.hostName}"; + users.users.root.shell = pkgs.zsh; networking.hostName = cfg.hostName; }; } diff --git a/modules/skyg/user.nix b/modules/skyg/user.nix index cc2cefe..fcd055c 100644 --- a/modules/skyg/user.nix +++ b/modules/skyg/user.nix @@ -4,10 +4,6 @@ with lib; let cfg = config.skyg; - gitconfigs = - (builtins.filterSource (path: type: type != "directory") ./gitconfigs); - gitconfigFiles = builtins.attrNames (builtins.readDir gitconfigs); - in { options = { @@ -15,6 +11,7 @@ in type = types.str; }; skyg.user = { + enabled = mkEnableOption ""; name = mkOption { type = types.str; }; @@ -39,101 +36,18 @@ in }; }; - config = { - programs.zsh.enable = true; - home-manager.users.root = { - home.stateVersion = cfg.home-manager.version; - programs.git = { - enable = true; - userName = "root"; - }; - programs.zsh = { - enable = true; - autosuggestion.enable = true; - }; - programs.zsh.oh-my-zsh.enable = true; - }; - home-manager.users.${cfg.user.name} = { - home = { - sessionVariables = { }; + config = + let + hm = (import ../home { stateVersion = cfg.home-manager.version; - shellAliases = { - cat = "bat"; - }; - packages = with pkgs; - [ jq nixfmt-classic devenv ipfetch nixd ] - ++ (if cfg.user.enableDevelopmentKit then [ - rye - uv - devbox - terraform - kubectl - ] else - [ ]); + }); + in + mkIf cfg.user.enabled + { + programs.zsh.enable = true; + home-manager.users.root = + (hm.makeRootUser { hostName = config.skyg.core.hostName; }) { pkgs = pkgs; }; + home-manager.users.${cfg.user.name} = + (hm.makeCommonUser cfg.user) { pkgs = pkgs; }; }; - programs = { - bat.enable = true; - neovim = { - enable = true; - defaultEditor = true; - viAlias = true; - vimAlias = true; - }; - direnv.enable = true; - lsd = { - enable = true; - enableAliases = true; - }; - git = { - enable = true; - userName = cfg.user.fullName; - userEmail = cfg.user.email; - delta = { enable = true; }; - extraConfig = { - color = { ui = "auto"; }; - push = { - default = "upstream"; - autoSetupRemote = true; - }; - init = { defaultBranch = "main"; }; - }; - includes = - (builtins.map (f: { path = gitconfigs + "/" + f; }) gitconfigFiles) - ++ cfg.user.extraGitConfigs; - }; - 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 ]; - }; - }; - }; - }; } - - -# user = { -# name = "ari"; -# fullName = "Ari Sosnovsky"; -# email = "ariel@sosnovsky.ca"; -# }; -# sumoUser = rec { -# name = "asosnovsky"; -# fullName = user.fullName; -# email = "${name}@sumologic.com"; -# homepath = "/Users/${name}"; -# extraGitConfigs = [{ path = "${homepath}/.config/mysumo/gitconfig"; }]; -# };