From d0caf89ffc06104cb9c077c299a96b778d5db79b Mon Sep 17 00:00:00 2001 From: Syndamia Date: Wed, 29 Nov 2023 19:44:57 +0200 Subject: (all) Overhaul, moved all package and their configs into packages/default.nix, reordered configuration.nix --- autoconfig.nix | 63 +++++++++++----------------------------------------------- 1 file changed, 12 insertions(+), 51 deletions(-) (limited to 'autoconfig.nix') 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)); } -- cgit v1.3.1-26-gb76a