mirror of
https://github.com/buckley310/nixos-config.git
synced 2024-12-21 19:24:15 +00:00
add lib.dirToAttrs
This commit is contained in:
parent
1c35a0a5a5
commit
9dd94dfa43
1 changed files with 14 additions and 18 deletions
32
flake.nix
32
flake.nix
|
@ -7,15 +7,10 @@
|
||||||
inherit (nixpkgs) lib;
|
inherit (nixpkgs) lib;
|
||||||
|
|
||||||
mypkgs = pkgs:
|
mypkgs = pkgs:
|
||||||
|
self.lib.dirToAttrs ./pkgs (x: pkgs.callPackage x { }) //
|
||||||
{
|
{
|
||||||
iso = import lib/gen-iso.nix lib pkgs.system;
|
iso = import lib/gen-iso.nix lib pkgs.system;
|
||||||
} //
|
};
|
||||||
(lib.mapAttrs'
|
|
||||||
(name: type: {
|
|
||||||
name = lib.removeSuffix ".nix" name;
|
|
||||||
value = pkgs.callPackage (./pkgs + "/${name}") { };
|
|
||||||
})
|
|
||||||
(builtins.readDir ./pkgs));
|
|
||||||
|
|
||||||
forAllSystems = lib.genAttrs [ "x86_64-linux" ];
|
forAllSystems = lib.genAttrs [ "x86_64-linux" ];
|
||||||
|
|
||||||
|
@ -41,6 +36,13 @@
|
||||||
lib = {
|
lib = {
|
||||||
gen-ssh-config = import lib/gen-ssh-config.nix lib;
|
gen-ssh-config = import lib/gen-ssh-config.nix lib;
|
||||||
ssh-keys = import lib/ssh-keys.nix;
|
ssh-keys = import lib/ssh-keys.nix;
|
||||||
|
|
||||||
|
dirToAttrs = dir: f: lib.mapAttrs'
|
||||||
|
(name: _: {
|
||||||
|
name = lib.removeSuffix ".nix" name;
|
||||||
|
value = f "${toString dir}/${name}";
|
||||||
|
})
|
||||||
|
(builtins.readDir dir);
|
||||||
};
|
};
|
||||||
|
|
||||||
nixosModules =
|
nixosModules =
|
||||||
|
@ -49,22 +51,16 @@
|
||||||
inherit (impermanence.nixosModules) impermanence;
|
inherit (impermanence.nixosModules) impermanence;
|
||||||
pkgs.nixpkgs.overlays = [ (_: mypkgs) ];
|
pkgs.nixpkgs.overlays = [ (_: mypkgs) ];
|
||||||
} //
|
} //
|
||||||
lib.mapAttrs'
|
self.lib.dirToAttrs ./modules import;
|
||||||
(name: type: {
|
|
||||||
name = lib.removeSuffix ".nix" name;
|
|
||||||
value = import (./modules + "/${name}");
|
|
||||||
})
|
|
||||||
(builtins.readDir ./modules);
|
|
||||||
|
|
||||||
nixosConfigurations = lib.genAttrs
|
nixosConfigurations = self.lib.dirToAttrs ./hosts
|
||||||
(builtins.attrNames (builtins.readDir ./hosts))
|
(dir:
|
||||||
(name:
|
let cfg = import dir;
|
||||||
let cfg = import (./hosts + "/${name}");
|
|
||||||
in lib.nixosSystem {
|
in lib.nixosSystem {
|
||||||
inherit (cfg) system;
|
inherit (cfg) system;
|
||||||
modules =
|
modules =
|
||||||
cfg.modules ++
|
cfg.modules ++
|
||||||
[{ networking.hostName = name; }] ++
|
[{ networking.hostName = builtins.baseNameOf dir; }] ++
|
||||||
(builtins.attrValues self.nixosModules);
|
(builtins.attrValues self.nixosModules);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue