mirror of
https://github.com/Gerg-L/nixos.git
synced 2025-12-10 00:43:56 -05:00
systems -> hosts
moved functions to /lib inputs over imports turned each module file into a nixosModule moved registry and $NIX_PATH pinning to /modules/pinning.nix
This commit is contained in:
parent
ee2beea680
commit
f43d0b741c
42 changed files with 224 additions and 240 deletions
61
lib/default.nix
Normal file
61
lib/default.nix
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
inputs @ {
|
||||
unstable,
|
||||
self,
|
||||
...
|
||||
}: let
|
||||
inherit (unstable) lib;
|
||||
|
||||
importAll = path:
|
||||
map
|
||||
(module: (import module inputs))
|
||||
(
|
||||
builtins.filter (lib.hasSuffix ".nix")
|
||||
(lib.filesystem.listFilesRecursive path)
|
||||
);
|
||||
|
||||
mkModules = path:
|
||||
lib.listToAttrs (
|
||||
map (
|
||||
name: {
|
||||
name = lib.removePrefix (toString path + "/") (lib.removeSuffix ".nix" (toString name));
|
||||
value = import name inputs;
|
||||
}
|
||||
)
|
||||
(
|
||||
builtins.filter (lib.hasSuffix ".nix")
|
||||
(lib.filesystem.listFilesRecursive path)
|
||||
)
|
||||
);
|
||||
in {
|
||||
inherit importAll mkModules;
|
||||
|
||||
withSystem = f:
|
||||
lib.fold lib.recursiveUpdate {}
|
||||
(map f ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"]);
|
||||
|
||||
mkSystems = system: names:
|
||||
lib.genAttrs names (
|
||||
name:
|
||||
lib.nixosSystem {
|
||||
inherit system;
|
||||
modules =
|
||||
builtins.attrValues self.nixosModules ++ importAll (self + "/hosts/" + name);
|
||||
}
|
||||
);
|
||||
mkDisko = names:
|
||||
lib.genAttrs names (
|
||||
name: (import (self + "/hosts/" + name + "/disko.nix") inputs)
|
||||
);
|
||||
|
||||
mkPkgs = pkgs: path:
|
||||
builtins.listToAttrs (
|
||||
map (module: {
|
||||
name = lib.removeSuffix ".nix" (builtins.baseNameOf module);
|
||||
value = pkgs.callPackage module {};
|
||||
})
|
||||
(
|
||||
builtins.filter (lib.hasSuffix ".nix")
|
||||
(lib.filesystem.listFilesRecursive path)
|
||||
)
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue