diff options
| author | seth <[email protected]> | 2024-05-05 11:35:18 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-05-05 11:35:18 -0400 |
| commit | 34a7a042a36b63eb6b900932b1e420e4b6014a57 (patch) | |
| tree | 40dace9b4bb7b6e99c5d54165d8eb203963f5306 /modules/flake | |
| parent | 9380483bdf038149fc308698e9f115b1474a0c85 (diff) | |
simplify some things (#353)
* flake: drop flake-parts
* flake: add back flake-parts
* flake: use flake module again for configurations
Diffstat (limited to 'modules/flake')
| -rw-r--r-- | modules/flake/configurations.nix | 46 | ||||
| -rw-r--r-- | modules/flake/default.nix | 2 | ||||
| -rw-r--r-- | modules/flake/openwrt.nix | 67 | ||||
| -rw-r--r-- | modules/flake/terranix.nix | 55 |
4 files changed, 29 insertions, 141 deletions
diff --git a/modules/flake/configurations.nix b/modules/flake/configurations.nix index 7b745fc..210f23e 100644 --- a/modules/flake/configurations.nix +++ b/modules/flake/configurations.nix @@ -1,33 +1,43 @@ { config, lib, - moduleLocation, flake-parts-lib, - withSystem, inputs, - self, + moduleLocation, + withSystem, ... }: let inherit (flake-parts-lib) mkSubmoduleOptions; inherit + (builtins) + removeAttrs + ; + + inherit (lib) attrValues literalExpression mapAttrs - mdDoc mkAliasOptionModule mkOption recursiveUpdate types ; - builderType = types.functionTo pkgsType; + inherit + (inputs) + nixpkgs + darwin + home-manager + ; + pkgsType = types.lazyAttrsOf types.raw; + builderType = types.functionTo pkgsType; defaultBuilderFor = { - nixos = inputs.nixpkgs.lib.nixosSystem; - darwin = (inputs.darwin or inputs.nix-darwin).lib.darwinSystem; + nixos = nixpkgs.lib.nixosSystem; + darwin = (inputs.nix-darwin or darwin).lib.darwinSystem; }; builderStringFor = { @@ -48,13 +58,13 @@ toSystem = type: name: args: args.builder ( - recursiveUpdate (builtins.removeAttrs args ["builder"]) { + recursiveUpdate (removeAttrs args ["builder"]) { modules = [ ../../systems/${name} {networking.hostName = name;} ] - ++ attrValues (self."${type}Modules" or {}) + ++ attrValues (inputs.self."${type}Modules" or {}) ++ (args.modules or []); specialArgs = applySpecialArgsFor args.system (args.specialArgs or {}); @@ -62,18 +72,18 @@ ); toUser = name: args: - inputs.home-manager.lib.homeManagerConfiguration ( + home-manager.lib.homeManagerConfiguration ( recursiveUpdate args { modules = [ - ../../users/${name} + ../../users/${name}/home.nix { _module.args.osConfig = {}; programs.home-manager.enable = true; } ] - ++ attrValues (self.homeModules or {}) + ++ attrValues (inputs.self.homeModules or {}) ++ (args.modules or []); extraSpecialArgs = let @@ -96,7 +106,7 @@ type = builderType; default = defaultBuilderFor.${type}; example = literalExpression (builderStringFor type); - description = mdDoc '' + description = '' Function to build this ${type}Configuration with ''; }; @@ -105,7 +115,7 @@ type = types.str; default = "x86_64-${kernelFor type}"; example = literalExpression "aarch64-${kernelFor type}"; - description = mdDoc '' + description = '' System to build this ${type}Configuration for ''; }; @@ -118,8 +128,10 @@ options = { pkgs = mkOption { type = pkgsType; + default = nixpkgs.legacyPackages.x86_64-linux; + defaultText = "inputs.nixpkgs.legacyPackages.x86_64-linux"; example = literalExpression "inputs.nixpkgs.legacyPackages.aarch64-linux"; - description = mdDoc '' + description = '' Instance of nixpkgs to use in this homeConfiguration ''; }; @@ -137,7 +149,7 @@ }; } ''; - description = mdDoc '' + description = '' Attribute set of `lib.${type}System` options. The names of each attribute will be used to import files in the `systems/` directory @@ -178,7 +190,7 @@ in { }; } ''; - description = mdDoc '' + description = '' Attribute set of `lib.homeManagerConfiguration` arguments. The name of each attribute will be used to import files in the `users/` directory. diff --git a/modules/flake/default.nix b/modules/flake/default.nix index 04c495d..8d671c2 100644 --- a/modules/flake/default.nix +++ b/modules/flake/default.nix @@ -1,5 +1,3 @@ { configurations = import ./configurations.nix; - openwrt = import ./openwrt.nix; - terranix = import ./terranix.nix; } diff --git a/modules/flake/openwrt.nix b/modules/flake/openwrt.nix deleted file mode 100644 index bdf4235..0000000 --- a/modules/flake/openwrt.nix +++ /dev/null @@ -1,67 +0,0 @@ -{ - config, - lib, - withSystem, - inputs, - ... -}: let - namespace = "openWrtImages"; - cfg = config.${namespace}; - - inherit - (lib) - literalExpression - mdDoc - mkOption - types - ; - - openWrtSubmodule = { - freeformType = types.attrsOf types.anything; - options = { - profile = mkOption { - type = types.str; - example = literalExpression "netgear_wac104"; - description = mdDoc '' - Device profile to build images for. - ''; - }; - - release = mkOption { - type = types.str; - default = "23.05.0"; - example = literalExpression "23.05.2"; - description = mdDoc '' - OpenWRT release to base image off of - ''; - }; - }; - }; -in { - options.${namespace} = mkOption { - type = types.attrsOf (types.submodule openWrtSubmodule); - default = {}; - description = mdDoc '' - Generated OpenWRT images - ''; - }; - - config.flake.legacyPackages.x86_64-linux = { - ${namespace} = withSystem "x86_64-linux" ( - {pkgs, ...}: let - profileFromRelease = release: - (inputs.openwrt-imagebuilder.lib.profiles { - inherit pkgs release; - }) - .identifyProfile; - - mkImage = {profile, ...} @ args: - inputs.openwrt-imagebuilder.lib.build ( - profileFromRelease args.release profile - // builtins.removeAttrs args ["profile" "release"] - ); - in - lib.mapAttrs (lib.const mkImage) cfg - ); - }; -} diff --git a/modules/flake/terranix.nix b/modules/flake/terranix.nix deleted file mode 100644 index 0d39043..0000000 --- a/modules/flake/terranix.nix +++ /dev/null @@ -1,55 +0,0 @@ -{ - lib, - flake-parts-lib, - inputs, - ... -}: let - namespace = "terranix"; - - inherit - (lib) - literalExpression - mkOption - mkPackageOption - types - ; - - inherit - (flake-parts-lib) - mkPerSystemOption - ; -in { - options = { - perSystem = mkPerSystemOption ({ - config, - pkgs, - system, - ... - }: let - cfg = config.${namespace}; - in { - options.${namespace} = { - modules = mkOption { - type = types.listOf types.unspecified; - default = []; - example = literalExpression "[ ./terranix ]"; - description = '' - Modules to use in this terranixConfiguration - ''; - }; - - package = mkPackageOption pkgs "opentofu" { - default = ["opentofu"]; - example = literalExpression "pkgs.opentofu.withPlugins (plugins: [ plugins.tailscale ] )"; - }; - }; - - config = { - packages.terranix = inputs.terranix.lib.terranixConfiguration { - inherit system; - inherit (cfg) modules; - }; - }; - }); - }; -} |
