Different hosts config layout + use IPs

main
kalle 2025-02-03 16:58:33 +01:00
parent 95cbc98ee3
commit 35bfc55356
5 changed files with 55 additions and 35 deletions

View File

@ -18,14 +18,17 @@
homelabConfig = import ./config.nix;
roles = import ./roles { inherit utils; };
hosts = import ./hosts.nix { inherit homelabConfig roles; };
hosts = import ./hosts.nix {
inherit homelabConfig roles;
lib = nixpkgs.lib;
};
in
{
nixosConfigurations = nixpkgs.lib.mapAttrs (
hostname: value:
_: value:
(utils.mkSystem {
inherit hosts;
hostConfig = (value // { inherit hostname; });
hostConfig = value;
})
) hosts;
};

View File

@ -1,37 +1,20 @@
{
roles,
homelabConfig,
lib,
...
}:
let
hlConfig = homelabConfig;
in
{
base = {
roles = [ ];
config = { };
stateVersion = "24.05";
};
nix-test = {
roles = with roles; [
traefik
sonarr
];
config = {
sonarr.domain = "sonarr2.${hlConfig.domain}";
traefik.wildcardDomains = [ hlConfig.domain ];
lib.attrsets.mapAttrs' (
name: _:
let
cfg = import (./hosts + "/${name}") {
inherit roles;
hlConfig = homelabConfig;
};
stateVersion = "24.05";
};
nix-test2 = {
roles = with roles; [
sonarr
];
config = {
sonarr.domain = "sonarr.${hlConfig.domain}";
};
stateVersion = "24.05";
};
}
hostname = cfg.hostname;
in
{
name = hostname;
value = cfg;
}
) (builtins.readDir ./hosts)

15
hosts/base.nix Normal file
View File

@ -0,0 +1,15 @@
{
roles,
hlConfig,
}:
{
hostname = "base";
managed = true;
ip = "192.168.10.98";
roles = with roles; [
];
config = {
};
stateVersion = "24.05";
}

19
hosts/nix-test.nix Normal file
View File

@ -0,0 +1,19 @@
{
roles,
hlConfig,
}:
{
hostname = "nix-test";
managed = true;
ip = "192.168.10.99";
roles = with roles; [
traefik
sonarr
];
config = {
sonarr.domain = "sonarr2.${hlConfig.domain}";
traefik.wildcardDomains = [ hlConfig.domain ];
};
stateVersion = "24.05";
}

View File

@ -14,7 +14,7 @@
{
name = "${hostname}-sonarr";
rule = "Host(`${config.sonarr.domain}`)";
target = "http://${hostname}.lan:8989";
target = "http://${config.ip}:8989";
}
];