Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commitf1f6b27853d6b2271817859bdc6eb2d33ea064aa (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-11-28 21:18:29 +0200
Committer
 Syndamia <kamen@syndamia.com>
2023-11-28 21:18:29 +0200
Files7a0e679ad9265c1272c2d8b62b1f85e719dcbecb
nix-f1f6b27853d6b2271817859bdc6eb2d33ea064aa.tar
nix-f1f6b27853d6b2271817859bdc6eb2d33ea064aa.tar.gz
nix-f1f6b27853d6b2271817859bdc6eb2d33ea064aa.zip
Parentfe8588af061dcd0f00d83d660a4006c8fea8fa5c (diff)
(autoconfig/packages) Made packages function as a variable in configurations
2 files changed, 36 insertions, 37 deletions
-rw-r--r--autoconfig.nix71
-rw-r--r--flake.nix2
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
}
diff --git a/flake.nix b/flake.nix
index daccdc7..7888cf8 100644
--- a/flake.nix
+++ b/flake.nix
@@ -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;
};