diff options
| -rw-r--r-- | flake.lock | 42 | ||||
| -rw-r--r-- | flake.nix | 4 | ||||
| -rw-r--r-- | modules/flake/configurations.nix | 179 | ||||
| -rw-r--r-- | parts/shell.nix | 2 | ||||
| -rw-r--r-- | systems/atlas/default.nix | 5 | ||||
| -rw-r--r-- | systems/caroline/default.nix | 5 | ||||
| -rw-r--r-- | systems/default.nix | 35 | ||||
| -rw-r--r-- | systems/glados-wsl/default.nix | 6 | ||||
| -rw-r--r-- | systems/glados/default.nix | 20 | ||||
| -rw-r--r-- | users/default.nix | 6 | ||||
| -rw-r--r-- | users/seth/base/standalone.nix | 3 |
11 files changed, 153 insertions, 154 deletions
@@ -89,26 +89,6 @@ "type": "github" } }, - "darwin": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1715901937, - "narHash": "sha256-eMyvWP56ZOdraC2IOvZo0/RTDcrrsqJ0oJWDC76JTak=", - "owner": "LnL7", - "repo": "nix-darwin", - "rev": "ffc01182f90118119930bdfc528c1ee9a39ecef8", - "type": "github" - }, - "original": { - "owner": "LnL7", - "repo": "nix-darwin", - "type": "github" - } - }, "fenix": { "inputs": { "nixpkgs": [ @@ -298,6 +278,26 @@ "type": "github" } }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1716329735, + "narHash": "sha256-ap51w+VqG21vuzyQ04WrhI2YbWHd3UGz0e7dc/QQmoA=", + "owner": "LnL7", + "repo": "nix-darwin", + "rev": "eac4f25028c1975a939c8f8fba95c12f8a25e01c", + "type": "github" + }, + "original": { + "owner": "LnL7", + "repo": "nix-darwin", + "type": "github" + } + }, "nix-index-database": { "inputs": { "nixpkgs": [ @@ -434,7 +434,6 @@ "agenix": "agenix", "arkenfox": "arkenfox", "catppuccin": "catppuccin", - "darwin": "darwin", "firefox-addons": "firefox-addons", "flake-checks": "flake-checks", "flake-parts": "flake-parts", @@ -442,6 +441,7 @@ "home-manager": "home-manager", "krunner-nix": "krunner-nix", "lanzaboote": "lanzaboote", + "nix-darwin": "nix-darwin", "nix-index-database": "nix-index-database", "nixinate": "nixinate", "nixos-wsl": "nixos-wsl", @@ -38,8 +38,8 @@ inputs = { nixpkgs.url = "nixpkgs/nixos-unstable"; nixpkgs-stable.url = "nixpkgs/nixos-23.11"; - darwin = { - url = "github:LnL7/nix-darwin/"; + nix-darwin = { + url = "github:LnL7/nix-darwin"; inputs.nixpkgs.follows = "nixpkgs"; }; diff --git a/modules/flake/configurations.nix b/modules/flake/configurations.nix index 312adcf..5b2d934 100644 --- a/modules/flake/configurations.nix +++ b/modules/flake/configurations.nix @@ -3,6 +3,7 @@ lib, flake-parts-lib, inputs, + self, moduleLocation, withSystem, ... @@ -11,40 +12,20 @@ inherit (builtins) + attrValues + mapAttrs removeAttrs ; inherit (lib) - attrValues + const literalExpression - mapAttrs - mkAliasOptionModule mkOption recursiveUpdate types ; - inherit - (inputs) - nixpkgs - darwin - home-manager - ; - - pkgsType = types.lazyAttrsOf types.raw; - builderType = types.functionTo pkgsType; - - defaultBuilderFor = { - nixos = nixpkgs.lib.nixosSystem; - darwin = (inputs.nix-darwin or darwin).lib.darwinSystem; - }; - - builderStringFor = { - nixos = "inputs.nixpkgs.lib.nixosSystem"; - darwin = "inputs.nix-darwin.lib.darwinSystem"; - }; - kernelFor = { nixos = "linux"; darwin = "darwin"; @@ -56,65 +37,71 @@ inputs' = withSystem system ({inputs', ...}: inputs'); }; - toSystem = type: name: args: + toSystem = type: { + modules ? [], + system, + specialArgs ? {}, + ... + } @ args: args.builder ( - recursiveUpdate (removeAttrs args ["builder"]) { - modules = - [ - ../../systems/${name} - {networking.hostName = name;} - ] - ++ attrValues (inputs.self."${type}Modules" or {}) - ++ (args.modules or []); - - specialArgs = applySpecialArgsFor args.system (args.specialArgs or {}); + removeAttrs args ["builder"] + // { + modules = modules ++ attrValues (self."${type}Modules" or {}); + specialArgs = applySpecialArgsFor system specialArgs; } ); - toUser = name: args: - home-manager.lib.homeManagerConfiguration ( - recursiveUpdate args { - modules = - [ - ../../users/${name}/home.nix - - { - _module.args.osConfig = {}; - programs.home-manager.enable = true; - } - ] - ++ attrValues (inputs.self.homeModules or {}) - ++ (args.modules or []); - - extraSpecialArgs = let - inherit (args.pkgs.stdenv.hostPlatform) system; - in - applySpecialArgsFor system (args.extraSpecialArgs or {}); + toUser = { + extraSpecialArgs ? {}, + modules ? [], + pkgs, + } @ args: + inputs.home-manager.lib.homeManagerConfiguration ( + args + // { + modules = modules ++ attrValues (self.homeManagerModules or {}); + extraSpecialArgs = applySpecialArgsFor pkgs.stdenv.hostPlatform.system extraSpecialArgs; } ); - mapSystems = type: mapAttrs (toSystem type); - mapUsers = mapAttrs toUser; + mapSystems = type: mapAttrs (const (toSystem type)); + mapUsers = mapAttrs (const toUser); mapNixOS = mapSystems "nixos"; mapDarwin = mapSystems "darwin"; systemsSubmodule = type: { - freeformType = types.attrsOf types.any; + freeformType = types.attrsOf types.anything; options = { - builder = mkOption { - type = builderType; - default = defaultBuilderFor.${type}; - example = literalExpression (builderStringFor type); - description = '' - Function to build this ${type}Configuration with - ''; - }; + builder = let + error = throw "System configuration of type `${type}` is not supported!"; + in + mkOption { + type = types.functionTo (types.lazyAttrsOf types.raw); + default = + { + nixos = inputs.nixpkgs.lib.nixosSystem; + darwin = inputs.nix-darwin.lib.darwinSystem; + } + .${type} + or error; + example = literalExpression ( + { + nixos = "inputs.nixpkgs.lib.nixosSystem"; + darwin = "inputs.nix-darwin.lib.darwinSystem"; + } + .${type} + or error + ); + description = '' + Function to build this ${type}Configuration with + ''; + }; system = mkOption { type = types.str; - default = "x86_64-${kernelFor type}"; - example = literalExpression "aarch64-${kernelFor type}"; + default = "x86_64-" + kernelFor.${type}; + example = literalExpression ("aarch64-" + kernelFor.${type}); description = '' System to build this ${type}Configuration for ''; @@ -123,12 +110,12 @@ }; usersSubmodule = { - freeformType = types.attrsOf types.any; + freeformType = types.attrsOf types.anything; options = { pkgs = mkOption { - type = pkgsType; - default = nixpkgs.legacyPackages.x86_64-linux; + type = types.lazyAttrsOf types.raw; + default = inputs.nixpkgs.legacyPackages.x86_64-linux; defaultText = "inputs.nixpkgs.legacyPackages.x86_64-linux"; example = literalExpression "inputs.nixpkgs.legacyPackages.aarch64-linux"; description = '' @@ -144,8 +131,8 @@ default = {}; example = literalExpression '' { - foo = { - system = "aarch64-${kernelFor type}"; + myComputer = { + system = "aarch64${kernelFor type}"; }; } ''; @@ -156,14 +143,6 @@ ''; }; in { - # i don't like prefixing so much with `flake` - imports = [ - (mkAliasOptionModule ["nixosModules"] ["flake" "nixosModules"]) - (mkAliasOptionModule ["darwinModules"] ["flake" "darwinModules"]) - (mkAliasOptionModule ["homeModules"] ["flake" "homeModules"]) - (mkAliasOptionModule ["flakeModules"] ["flake" "flakeModules"]) - ]; - options = { flake = mkSubmoduleOptions { darwinModules = mkOption { @@ -176,30 +155,32 @@ in { }; }; - nixosConfigurations = mkSystemOptions "nixos"; - darwinConfigurations = mkSystemOptions "darwin"; + configurations = { + nixos = mkSystemOptions "nixos"; + darwin = mkSystemOptions "darwin"; - homeConfigurations = mkOption { - type = types.attrsOf (types.submodule usersSubmodule); - default = {}; - example = literalExpression '' - { - john = { - pkgs = inputs.nixpkgs.legacyPackages.aarch64-linux; - }; - } - ''; - description = '' - Attribute set of `lib.homeManagerConfiguration` arguments. The - name of each attribute will be used to import files in the `users/` - directory. - ''; + home = mkOption { + type = types.attrsOf (types.submodule usersSubmodule); + default = {}; + example = literalExpression '' + { + john = { + pkgs = inputs.nixpkgs.legacyPackages.aarch64-linux; + }; + } + ''; + description = '' + Attribute set of `lib.homeManagerConfiguration` arguments. The + name of each attribute will be used to import files in the `users/` + directory. + ''; + }; }; }; config.flake = { - nixosConfigurations = mapNixOS config.nixosConfigurations; - darwinConfigurations = mapDarwin config.darwinConfigurations; - homeConfigurations = mapUsers config.homeConfigurations; + nixosConfigurations = mapNixOS config.configurations.nixos; + darwinConfigurations = mapDarwin config.configurations.darwin; + homeConfigurations = mapUsers config.configurations.home; }; } diff --git a/parts/shell.nix b/parts/shell.nix index ada1ecf..aa24e33 100644 --- a/parts/shell.nix +++ b/parts/shell.nix @@ -25,7 +25,7 @@ pkgs.just self'.packages.opentofu ] - ++ lib.optional pkgs.stdenv.isDarwin [inputs'.darwin.packages.darwin-rebuild] + ++ lib.optional pkgs.stdenv.isDarwin [inputs'.nix-darwin.packages.darwin-rebuild] ++ lib.optionals pkgs.stdenv.isLinux [pkgs.nixos-rebuild inputs'.agenix.packages.agenix]; }; }; diff --git a/systems/atlas/default.nix b/systems/atlas/default.nix index df55b62..7145297 100644 --- a/systems/atlas/default.nix +++ b/systems/atlas/default.nix @@ -27,7 +27,10 @@ loader.efi.canTouchEfiVariables = true; }; - networking.domain = "getchoo.com"; + networking = { + domain = "getchoo.com"; + hostName = "atlas"; + }; system.stateVersion = "23.05"; } diff --git a/systems/caroline/default.nix b/systems/caroline/default.nix index f41ae12..932e85c 100644 --- a/systems/caroline/default.nix +++ b/systems/caroline/default.nix @@ -8,7 +8,10 @@ "prismlauncher" ]; - networking.computerName = config.networking.hostName; + networking = { + computerName = config.networking.hostName; + hostName = "caroline"; + }; nix.settings.trusted-users = ["seth"]; diff --git a/systems/default.nix b/systems/default.nix index c608e9c..33736e6 100644 --- a/systems/default.nix +++ b/systems/default.nix @@ -3,26 +3,29 @@ self, ... }: { - darwinConfigurations = { - caroline = { - system = "x86_64-darwin"; + configurations = { + darwin = { + caroline = { + modules = [./caroline]; + }; }; - }; - nixosConfigurations = let - stable = inputs.nixpkgs-stable.lib.nixosSystem; - in { - glados = { - system = "x86_64-linux"; - }; + nixos = let + stable = inputs.nixpkgs-stable.lib.nixosSystem; + in { + glados = { + modules = [./glados]; + }; - glados-wsl = { - system = "x86_64-linux"; - }; + glados-wsl = { + modules = [./glados-wsl]; + }; - atlas = { - builder = stable; - system = "aarch64-linux"; + atlas = { + builder = stable; + modules = [./atlas]; + system = "aarch64-linux"; + }; }; }; diff --git a/systems/glados-wsl/default.nix b/systems/glados-wsl/default.nix index a0b02bf..88b5184 100644 --- a/systems/glados-wsl/default.nix +++ b/systems/glados-wsl/default.nix @@ -30,6 +30,10 @@ ]; }; + networking.hostName = "glados-wsl"; + + system.stateVersion = "23.11"; + traits.tailscale.enable = true; wsl = { @@ -43,6 +47,4 @@ startMenuLaunchers = false; interop.includePath = false; }; - - system.stateVersion = "23.11"; } diff --git a/systems/glados/default.nix b/systems/glados/default.nix index a0654f8..491285d 100644 --- a/systems/glados/default.nix +++ b/systems/glados/default.nix @@ -13,15 +13,7 @@ environment.systemPackages = [pkgs.obs-studio]; - traits = { - containers.enable = true; - nvidia = { - enable = true; - nvk.enable = true; - }; - tailscale.enable = true; - zram.enable = true; - }; + networking.hostName = "glados"; security.tpm2 = { enable = true; @@ -35,4 +27,14 @@ }; system.stateVersion = "23.11"; + + traits = { + containers.enable = true; + nvidia = { + enable = true; + nvk.enable = true; + }; + tailscale.enable = true; + zram.enable = true; + }; } diff --git a/users/default.nix b/users/default.nix index 32bb9dc..7618f9c 100644 --- a/users/default.nix +++ b/users/default.nix @@ -1,5 +1,7 @@ { - homeConfigurations = { - seth = {}; + configurations.home = { + seth = { + modules = [./seth/home.nix]; + }; }; } diff --git a/users/seth/base/standalone.nix b/users/seth/base/standalone.nix index 941d0a7..ce8863c 100644 --- a/users/seth/base/standalone.nix +++ b/users/seth/base/standalone.nix @@ -12,6 +12,9 @@ in { }; config = lib.mkIf enable { + _module.args.osConfig = {}; + programs.home-manager.enable = true; + home = { username = "seth"; homeDirectory = |
