mirror of
https://github.com/Gerg-L/nixos.git
synced 2025-12-10 00:43:56 -05:00
moved functions to /lib inputs over imports turned each module file into a nixosModule moved registry and $NIX_PATH pinning to /modules/pinning.nix
61 lines
1.4 KiB
Nix
61 lines
1.4 KiB
Nix
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)
|
|
)
|
|
);
|
|
}
|