diff options
| Commit | f1f6b27853d6b2271817859bdc6eb2d33ea064aa (patch) | |
|---|---|---|
| Author | 2023-11-28 21:18:29 +0200 | |
| Committer | 2023-11-28 21:18:29 +0200 | |
| Files | 7a0e679ad9265c1272c2d8b62b1f85e719dcbecb | |
| nix-f1f6b27853d6b2271817859bdc6eb2d33ea064aa.tar nix-f1f6b27853d6b2271817859bdc6eb2d33ea064aa.tar.gz nix-f1f6b27853d6b2271817859bdc6eb2d33ea064aa.zip | ||
| Parent | fe8588af061dcd0f00d83d660a4006c8fea8fa5c (diff) | |
(autoconfig/packages) Made packages function as a variable in configurations
2 files changed, 36 insertions, 37 deletions
| -rw-r--r-- | autoconfig.nix | 71 | ||||
| -rw-r--r-- | flake.nix | 2 |
diff --git a/autoconfig.nix b/autoconfig.nix index 74424f1..8f74c7f 100644 --- a/autoconfig.nix +++ b/autoconfig.nix @@ -1,4 +1,4 @@ -{ self, inputs, ... }: +{ inputs, ... }: let inherit (inputs) nixpkgs; inherit (nixpkgs) lib; @@ -12,54 +12,53 @@ let else if builtins.isList (builtins.head values) then lib.concatLists (builtins.filter (val: builtins.isList val) values) else - lib.last values - ) + lib.last values) attrset; in - recurse; + recurse; in { configurations = lib.mapAttrs (dir: _: let inherit (import ./machines/${dir}/sysidentity.nix) sysidentity; - in lib.nixosSystem { + + 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 == "list" then + _mergeAttrs [ + acc + { + environment.systemPackages = pkg-settings; + }] + else + _mergeAttrs [ + acc + (lib.filterAttrs (name: _: name != "ref") pkg-settings) + { + environment.systemPackages = [pkg-settings.ref]; + }]) + {} + package-group; + in + _mergeAttrs [config config-from-group]) + {} + package-groups; # TODO: filter on machine type + + in + lib.nixosSystem { system = sysidentity.arch; modules = [ ./machines/${dir}/hardware-configuration.nix ./configuration.nix - self.packages + packages ]; }) (lib.filterAttrs (_: type: type == "directory") (builtins.readDir ./machines)); - - packages = - let - package-groups = import ./packages/default.nix { inherit nixpkgs; }; - in - lib.foldlAttrs - (config: _: package-group: - let - config-from-group = - lib.foldlAttrs - (acc: pkg-name: pkg-settings: - if pkg-name == "list" then - _mergeAttrs [ - acc - { - environment.systemPackages = pkg-settings; - }] - else - _mergeAttrs [ - acc - (lib.filterAttrs (name: _: name != "ref") pkg-settings) - { - environment.systemPackages = [pkg-settings.ref]; - }]) - {} - package-group; - in - _mergeAttrs [config config-from-group]) - {} - package-groups; # TODO: filter on machine type } @@ -7,7 +7,7 @@ outputs = { self, nixpkgs, ... }@inputs: let - autoconfig = import ./autoconfig.nix { self = autoconfig; inherit inputs; }; + autoconfig = import ./autoconfig.nix { inherit inputs; }; in { nixosConfigurations = autoconfig.configurations; }; |
