nixos-configs/lib/nixos.nix

43 lines
732 B
Nix
Raw Normal View History

2024-08-20 22:58:24 +02:00
{
inputs,
lib,
pkgs,
...
}:
2023-03-20 22:35:11 +01:00
2024-08-20 22:58:24 +02:00
let
sys = "x86_64-linux";
in
rec {
mkHost =
path:
attrs@{
system ? sys,
...
}:
lib.nixosSystem {
2023-03-20 22:35:11 +01:00
inherit system;
2024-08-20 22:58:24 +02:00
specialArgs = {
inherit lib inputs system;
};
2023-03-20 22:35:11 +01:00
modules = [
{
nixpkgs.pkgs = pkgs;
nix.registry.nixpkgs.flake = inputs.nixpkgs;
2024-08-20 22:58:24 +02:00
networking.hostName = lib.mkDefault (lib.removeSuffix ".nix" (baseNameOf path));
2023-03-20 22:35:11 +01:00
}
2024-08-20 22:58:24 +02:00
(lib.filterAttrs (n: v: !lib.elem n [ "system" ]) attrs)
2023-03-20 22:35:11 +01:00
../common.nix
(import path)
];
};
2024-08-20 22:58:24 +02:00
mapHosts =
dir:
attrs@{
system ? system,
...
}:
lib.my.mapModules dir (hostPath: mkHost hostPath attrs);
2023-03-20 22:35:11 +01:00
}