nix-infra/helper.nix

32 lines
967 B
Nix
Raw Permalink Normal View History

2023-07-30 01:38:31 +02:00
{ nixpkgs, ... }:
{
generateColmenaHost = name: {
site,
modules,
...
}: {
deployment = {
targetHost = "${name}.${site}.grzb.de";
targetUser = "colmena-deploy";
};
2023-07-27 21:59:24 +02:00
2023-07-30 01:38:31 +02:00
# Set imports and optionally import colmena secrets configuration
imports = modules ++ nixpkgs.lib.optional (builtins.pathExists ./config/hosts/${name}/secrets.nix) ./config/hosts/${name}/secrets.nix;
2023-07-30 01:38:31 +02:00
};
2023-07-27 21:59:24 +02:00
generateNixConfiguration = name: specialArgs: {
2023-07-30 01:38:31 +02:00
hostNixpkgs,
system,
modules,
...
}:
let
# Filter attritubes starting with _ to avoid infinite recursion when building with hydra
# TODO: Why does this happen?
filter = name: host: (builtins.substring 0 1 name) != "_";
in
(nixpkgs.lib.filterAttrs filter (hostNixpkgs.lib.nixosSystem {
inherit system modules specialArgs;
})).config.system.build.toplevel; # Builds the entire NixOS system, see: https://nixos.org/manual/nixos/stable/#sec-building-parts
2023-07-27 21:59:24 +02:00
}