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;
|
||||
|
||||
mypkgs = pkgs:
|
||||
self.lib.dirToAttrs ./pkgs (x: pkgs.callPackage x { }) //
|
||||
{
|
||||
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" ];
|
||||
|
||||
|
@ -41,6 +36,13 @@
|
|||
lib = {
|
||||
gen-ssh-config = import lib/gen-ssh-config.nix lib;
|
||||
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 =
|
||||
|
@ -49,22 +51,16 @@
|
|||
inherit (impermanence.nixosModules) impermanence;
|
||||
pkgs.nixpkgs.overlays = [ (_: mypkgs) ];
|
||||
} //
|
||||
lib.mapAttrs'
|
||||
(name: type: {
|
||||
name = lib.removeSuffix ".nix" name;
|
||||
value = import (./modules + "/${name}");
|
||||
})
|
||||
(builtins.readDir ./modules);
|
||||
self.lib.dirToAttrs ./modules import;
|
||||
|
||||
nixosConfigurations = lib.genAttrs
|
||||
(builtins.attrNames (builtins.readDir ./hosts))
|
||||
(name:
|
||||
let cfg = import (./hosts + "/${name}");
|
||||
nixosConfigurations = self.lib.dirToAttrs ./hosts
|
||||
(dir:
|
||||
let cfg = import dir;
|
||||
in lib.nixosSystem {
|
||||
inherit (cfg) system;
|
||||
modules =
|
||||
cfg.modules ++
|
||||
[{ networking.hostName = name; }] ++
|
||||
[{ networking.hostName = builtins.baseNameOf dir; }] ++
|
||||
(builtins.attrValues self.nixosModules);
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue