diff options
| Commit | d0caf89ffc06104cb9c077c299a96b778d5db79b (patch) | |
|---|---|---|
| Author | 2023-11-29 19:44:57 +0200 | |
| Committer | 2023-11-29 19:44:57 +0200 | |
| Files | 1f4850021bc37dd9a0531206e60fcf795b343461 /autoconfig.nix | |
| nix-d0caf89ffc06104cb9c077c299a96b778d5db79b.tar nix-d0caf89ffc06104cb9c077c299a96b778d5db79b.tar.gz nix-d0caf89ffc06104cb9c077c299a96b778d5db79b.zip | ||
| Parent | 3c2f7173c7620e14ef349ab36df14bf07f109d66 (diff) | |
(all) Overhaul, moved all package and their configs into packages/default.nix, reordered configuration.nix
1 files changed, 12 insertions, 51 deletions
| -rw-r--r-- | autoconfig.nix | 63 |
diff --git a/autoconfig.nix b/autoconfig.nix index 06021ee..e57d9e1 100644 --- a/autoconfig.nix +++ b/autoconfig.nix @@ -2,20 +2,6 @@ let inherit (inputs) nixpkgs; inherit (nixpkgs) lib; - _mergeAttrs = - let - recurse = attrset: - lib.zipAttrsWith - (name: values: - if builtins.isAttrs (builtins.head values) then - recurse (builtins.filter (val: builtins.isAttrs val) values) - else if builtins.isList (builtins.head values) then - lib.concatLists (builtins.filter (val: builtins.isList val) values) - else - lib.last values) - attrset; - in - recurse; in { configurations = lib.mapAttrs @@ -23,50 +9,25 @@ in { let inherit (import ./machines/${dir}/sysidentity.nix) sysidentity; - package-groups = import ./packages { pkgs = nixpkgs.legacyPackages.${sysidentity.arch}; }; - packages = - lib.foldlAttrs - (config: _: package-group: - let - config-from-group = - lib.foldlAttrs - (acc: pkg-name: pkg-settings: - if pkg-name == "for" then - acc - else if pkg-name == "list" then - _mergeAttrs [ - acc - { - environment.systemPackages = pkg-settings; - }] - else - _mergeAttrs [ - acc - (lib.filterAttrs (name: _: name != "ref") pkg-settings) - (if pkg-settings ? ref then - { - environment.systemPackages = [pkg-settings.ref]; - } - else - {} )]) - {} - package-group; - in - _mergeAttrs [config config-from-group]) - {} + package-modules = + lib.mapAttrsToList + (_: module: module) (lib.filterAttrs - (_: prop: ((prop ? for.type) -> (builtins.elem sysidentity.type prop.for.type)) && - ((prop ? for.name) -> (builtins.elem sysidentity.name prop.for.name))) - package-groups); - + (name: _: + (lib.hasInfix "_" name) -> (lib.hasPrefix (sysidentity.type + "_") name)) + (import ./packages)); in lib.nixosSystem { system = sysidentity.arch; modules = [ ./machines/${dir}/hardware-configuration.nix ./configuration.nix - packages - ]; + ({ ... }: { networking.hostName = sysidentity.name; }) + ] + ++ (if lib.pathIsRegularFile ./machines/${dir}/configuration.nix + then [ ./machines/${dir}/configuration.nix ] + else []) + ++ package-modules; }) (lib.filterAttrs (_: type: type == "directory") (builtins.readDir ./machines)); } |
