42 lines
853 B
Nix
Executable file
42 lines
853 B
Nix
Executable file
{
|
|
inputs,
|
|
lib,
|
|
self,
|
|
...
|
|
}: let
|
|
inherit (inputs.nixpkgs.lib) nixosSystem;
|
|
inherit (lib.modules) mkDefault;
|
|
inherit (lib.strings) removeSuffix;
|
|
inherit (self.modules) mapModules;
|
|
in rec {
|
|
mkHost = path: {
|
|
system,
|
|
pkgsFor,
|
|
...
|
|
}:
|
|
nixosSystem {
|
|
inherit system;
|
|
|
|
specialArgs = { inherit lib inputs system; };
|
|
|
|
modules = [
|
|
{
|
|
nixpkgs.pkgs = pkgsFor.${system};
|
|
nixpkgs.hostPlatform = lib.mkDefault system;
|
|
networking.hostName =
|
|
mkDefault (removeSuffix ".nix" (baseNameOf path));
|
|
}
|
|
../. # /default.nix
|
|
(import path)
|
|
];
|
|
};
|
|
|
|
mapHosts = dir: attrs:
|
|
mapModules dir (hostPath:
|
|
let
|
|
metaPath = "${hostPath}/meta.nix";
|
|
meta = import metaPath;
|
|
in
|
|
mkHost hostPath (attrs // meta)
|
|
);
|
|
}
|