diff options
| -rw-r--r-- | flake.nix | 94 | ||||
| -rw-r--r-- | users/seth/default.nix | 69 | ||||
| -rw-r--r-- | users/seth/desktop/default.nix | 7 | ||||
| -rw-r--r-- | users/seth/home.nix | 18 | ||||
| -rw-r--r-- | util/default.nix | 2 | ||||
| -rw-r--r-- | util/host.nix | 12 | ||||
| -rw-r--r-- | util/user.nix | 97 |
7 files changed, 178 insertions, 121 deletions
@@ -23,41 +23,27 @@ supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"]; forAllSystems = nixpkgs.lib.genAttrs supportedSystems; nixpkgsFor = forAllSystems (system: import nixpkgs {inherit system;}); + util = import ./util {inherit inputs home-manager;}; inherit (util) host user; - in { - homeConfigurations = { - seth = user.mkHMUser { - username = "seth"; - stateVersion = "23.05"; - channel = nixpkgsUnstable; - modules = []; - extraSpecialArgs = { + + seth = { + specialArgs ? {}, + pkgs ? nixpkgsUnstable, + }: + forAllSystems (system: + import ./users/seth { + inherit pkgs specialArgs system user; nixpkgsStable = nixpkgs; - standalone = true; - }; - }; - }; + }); + in { + homeConfigurations = forAllSystems (system: { + inherit ((seth {}).${system}.hm) seth; + }); nixosConfigurations = - (host.mkHost { + (host.mkHost rec { name = "glados"; - modules = [ - nixos-hardware.nixosModules.common-cpu-amd-pstate - nixos-hardware.nixosModules.common-gpu-nvidia-nonprime - nixos-hardware.nixosModules.common-pc-ssd - lanzaboote.nixosModules.lanzaboote - nur.nixosModules.nur - - ./users/seth - { - nixpkgs.overlays = let - localOverlay = _: super: { - discord-canary = super.discord-canary.override {withOpenASAR = true;}; - }; - in [nur.overlay localOverlay]; - } - ]; specialArgs = { desktop = "gnome"; nixpkgsStable = nixpkgs; @@ -66,25 +52,26 @@ }; version = "23.05"; pkgs = nixpkgsUnstable; + modules = + [ + nixos-hardware.nixosModules.common-cpu-amd-pstate + nixos-hardware.nixosModules.common-gpu-nvidia-nonprime + nixos-hardware.nixosModules.common-pc-ssd + lanzaboote.nixosModules.lanzaboote + nur.nixosModules.nur + + { + nixpkgs.overlays = let + localOverlay = _: super: { + discord-canary = super.discord-canary.override {withOpenASAR = true;}; + }; + in [nur.overlay localOverlay]; + } + ] + ++ (seth {inherit specialArgs pkgs;}).x86_64-linux.system; }) - // (host.mkHost { + // (host.mkHost rec { name = "glados-wsl"; - modules = [ - nixos-wsl.nixosModules.wsl - - { - wsl = { - enable = true; - defaultUser = "seth"; - nativeSystemd = true; - wslConf.network.hostname = "glados-wsl"; - startMenuLaunchers = false; - interop.includePath = false; - }; - } - - ./users/seth - ]; specialArgs = { desktop = ""; nixpkgsStable = nixpkgs; @@ -93,6 +80,21 @@ }; version = "23.05"; pkgs = nixpkgsUnstable; + modules = + [ + nixos-wsl.nixosModules.wsl + { + wsl = { + enable = true; + defaultUser = "seth"; + nativeSystemd = true; + wslConf.network.hostname = "glados-wsl"; + startMenuLaunchers = false; + interop.includePath = false; + }; + } + ] + ++ (seth {inherit specialArgs pkgs;}).x86_64-linux.system; }); formatter = forAllSystems (system: nixpkgsFor.${system}.alejandra); diff --git a/users/seth/default.nix b/users/seth/default.nix index 1476323..140eac8 100644 --- a/users/seth/default.nix +++ b/users/seth/default.nix @@ -1,42 +1,39 @@ { - config, pkgs, - home-manager, - desktop, - ... -}: { - users.users.seth = { - extraGroups = ["wheel"]; - isNormalUser = true; - hashedPassword = "***REMOVED***"; - shell = pkgs.fish; + specialArgs, + user, + system ? "x86_64-linux", + nixpkgsStable, +}: let + common = { + username = "seth"; + stateVersion = "23.05"; }; - - programs.fish.enable = true; - - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - users.seth = { - imports = - [ - ./home.nix - ./shell - ] - ++ ( - if (desktop != "") - then [./desktop] - else [] - ); - - home.stateVersion = config.system.stateVersion; - - nixpkgs.config = { - allowUnfree = true; - allowUnsupportedSystem = true; +in + with user; { + hm.seth = mkHMUser { + inherit (common) username stateVersion; + inherit system; + channel = pkgs; + extraSpecialArgs = { + inherit nixpkgsStable; + standalone = true; + desktop = ""; }; + }; - systemd.user.startServices = true; + system = mkUser { + inherit (common) username stateVersion; + inherit system; + extraGroups = ["wheel"]; + extraModules = [ + { + programs.fish.enable = true; + } + ]; + extraSpecialArgs = specialArgs; + hashedPassword = "***REMOVED***"; + shell = pkgs.legacyPackages.${system}.fish; + hm = true; }; - }; -} + } diff --git a/users/seth/desktop/default.nix b/users/seth/desktop/default.nix index 3a871ee..cf87b3f 100644 --- a/users/seth/desktop/default.nix +++ b/users/seth/desktop/default.nix @@ -11,7 +11,12 @@ ++ ( if (desktop == "gnome") then [./gnome.nix] - else [./plasma.nix] + else [] + ) + ++ ( + if (desktop == "plasma") + then [./plasma.nix] + else [] ); home.packages = with pkgs; [ diff --git a/users/seth/home.nix b/users/seth/home.nix index 4852ad0..5c175e7 100644 --- a/users/seth/home.nix +++ b/users/seth/home.nix @@ -1,8 +1,16 @@ -_: { - imports = [ - ./programs - ./shell - ]; +{desktop, ...}: let + usingDesktop = desktop != ""; +in { + imports = + [ + ./programs + ./shell + ] + ++ ( + if usingDesktop + then [./desktop] + else [] + ); nix.settings.warn-dirty = false; } diff --git a/util/default.nix b/util/default.nix index 2d42909..0fb91b5 100644 --- a/util/default.nix +++ b/util/default.nix @@ -1,4 +1,4 @@ {home-manager, ...}: { - host = import ./host.nix {inherit home-manager;}; + host = import ./host.nix {}; user = import ./user.nix {inherit home-manager;}; } diff --git a/util/host.nix b/util/host.nix index da2c692..2c7906c 100644 --- a/util/host.nix +++ b/util/host.nix @@ -1,4 +1,4 @@ -{home-manager, ...}: { +_: { mkHost = { name, modules, @@ -18,6 +18,7 @@ ({pkgs, ...}: { system.stateVersion = version; networking.hostName = mkDefault name; + # enable non-free packages nixpkgs.config = { allowUnfree = true; @@ -30,15 +31,6 @@ settings.experimental-features = ["nix-command" "flakes"]; }; }) - - home-manager.nixosModules.home-manager - { - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - extraSpecialArgs = specialArgs; - }; - } ] ++ modules; }; diff --git a/util/user.nix b/util/user.nix index 366112f..3953f11 100644 --- a/util/user.nix +++ b/util/user.nix @@ -1,10 +1,22 @@ -{home-manager, ...}: { +{home-manager, ...}: let + commonHM = { + nixpkgs.config = { + allowUnfree = true; + allowUnsupportedSystem = true; + }; + xdg.configFile."nixpkgs/config.nix".text = '' + { + allowUnfree = true; + } + ''; + }; +in { mkHMUser = { username, - stateVersion ? "22.11", - system ? "x86_64-linux", channel, modules ? [], + stateVersion ? "22.11", + system ? "x86_64-linux", extraSpecialArgs ? {}, }: home-manager.lib.homeManagerConfiguration { @@ -13,27 +25,68 @@ modules = [ ../users/${username}/home.nix - { - nixpkgs.config = { - allowUnfree = true; - allowUnsupportedSystem = true; - }; - - nix = { - package = channel.legacyPackages.${system}.nixFlakes; - settings.experimental-features = ["nix-command" "flakes"]; - }; + ({pkgs, ...}: + { + home = { + inherit username stateVersion; + homeDirectory = "/home/${username}"; + }; - systemd.user.startServices = true; - - home = { - inherit username stateVersion; - homeDirectory = "/home/${username}"; - }; - - programs.home-manager.enable = true; - } + programs.home-manager.enable = true; + nix = { + package = pkgs.nixFlakes; + settings.experimental-features = ["nix-command" "flakes"]; + }; + } + // commonHM) ] ++ modules; }; + mkUser = { + username, + extraGroups ? [], + extraModules ? [], + extraSpecialArgs ? {}, + hashedPassword, + hm ? false, + shell, + stateVersion, + system ? "x86_64-linux", + }: + [ + { + users.users.${username} = { + inherit extraGroups hashedPassword shell; + isNormalUser = true; + }; + } + ] + ++ extraModules + ++ ( + if hm + then [ + home-manager.nixosModules.home-manager + { + home-manager = { + inherit extraSpecialArgs; + useGlobalPkgs = true; + useUserPackages = true; + users.${username} = + { + imports = [ + ../users/${username}/home.nix + ]; + home.stateVersion = stateVersion; + } + // commonHM + // ( + if builtins.match ".*-linux" system != null + then {systemd.user.startServices = true;} + else {} + ); + }; + } + ] + else [] + ); } |
