config/utils.nix

53 lines
1.4 KiB
Nix
Raw Normal View History

2025-02-04 05:26:51 +01:00
{
inputs,
...
}:
2024-11-17 20:28:14 +01:00
{
mkSystem =
{ hostConfig }:
{
2025-02-04 05:26:51 +01:00
deployment = {
targetHost = hostConfig.ip;
targetUser = "maintenance";
};
imports = [
2024-11-22 18:05:37 +01:00
inputs.impermanence.nixosModules.impermanence
2024-12-26 19:41:49 +01:00
inputs.sops-nix.nixosModules.sops
2024-12-26 17:22:00 +01:00
./systems/base/configuration.nix
(
{ ... }:
{
2024-12-26 19:41:49 +01:00
sops.defaultSopsFile = ./secrets + "/${hostConfig.hostname}.yaml";
2024-12-26 20:22:43 +01:00
sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
2024-12-26 19:41:49 +01:00
# Disable automatic pgp key generation based on ssh keys
sops.gnupg.sshKeyPaths = [ ];
2025-02-03 17:23:12 +01:00
networking = {
hostName = hostConfig.hostname;
2025-02-04 05:26:51 +01:00
interfaces.eth0.ipv4.addresses = [
2025-02-03 17:23:12 +01:00
{
address = hostConfig.ip;
prefixLength = 24;
}
];
2025-02-03 17:27:53 +01:00
nameservers = [ "192.168.10.1" ];
2025-02-03 17:23:12 +01:00
defaultGateway = {
address = "192.168.10.1";
2025-02-04 05:26:51 +01:00
interface = "eth0";
2025-02-03 17:23:12 +01:00
};
};
2024-12-26 17:22:00 +01:00
system.stateVersion = hostConfig.stateVersion;
}
)
({ ... }: hostConfig.config)
] ++ builtins.map (role: role.nixosModule) hostConfig.roles;
2024-11-17 20:28:14 +01:00
};
2024-12-26 17:22:00 +01:00
mkRole = cfg: {
inherit (cfg) name description nixosModule;
traefikRoutes = cfg.traefikRoutes or ({ ... }: [ ]);
};
2024-11-17 20:28:14 +01:00
}