Different hosts config layout + use IPs
parent
95cbc98ee3
commit
35bfc55356
|
@ -18,14 +18,17 @@
|
||||||
|
|
||||||
homelabConfig = import ./config.nix;
|
homelabConfig = import ./config.nix;
|
||||||
roles = import ./roles { inherit utils; };
|
roles = import ./roles { inherit utils; };
|
||||||
hosts = import ./hosts.nix { inherit homelabConfig roles; };
|
hosts = import ./hosts.nix {
|
||||||
|
inherit homelabConfig roles;
|
||||||
|
lib = nixpkgs.lib;
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
nixosConfigurations = nixpkgs.lib.mapAttrs (
|
nixosConfigurations = nixpkgs.lib.mapAttrs (
|
||||||
hostname: value:
|
_: value:
|
||||||
(utils.mkSystem {
|
(utils.mkSystem {
|
||||||
inherit hosts;
|
inherit hosts;
|
||||||
hostConfig = (value // { inherit hostname; });
|
hostConfig = value;
|
||||||
})
|
})
|
||||||
) hosts;
|
) hosts;
|
||||||
};
|
};
|
||||||
|
|
45
hosts.nix
45
hosts.nix
|
@ -1,37 +1,20 @@
|
||||||
{
|
{
|
||||||
roles,
|
roles,
|
||||||
homelabConfig,
|
homelabConfig,
|
||||||
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
lib.attrsets.mapAttrs' (
|
||||||
hlConfig = homelabConfig;
|
name: _:
|
||||||
in
|
let
|
||||||
{
|
cfg = import (./hosts + "/${name}") {
|
||||||
base = {
|
inherit roles;
|
||||||
roles = [ ];
|
hlConfig = homelabConfig;
|
||||||
config = { };
|
|
||||||
stateVersion = "24.05";
|
|
||||||
};
|
|
||||||
|
|
||||||
nix-test = {
|
|
||||||
roles = with roles; [
|
|
||||||
traefik
|
|
||||||
sonarr
|
|
||||||
];
|
|
||||||
config = {
|
|
||||||
sonarr.domain = "sonarr2.${hlConfig.domain}";
|
|
||||||
traefik.wildcardDomains = [ hlConfig.domain ];
|
|
||||||
};
|
};
|
||||||
stateVersion = "24.05";
|
hostname = cfg.hostname;
|
||||||
};
|
in
|
||||||
|
{
|
||||||
nix-test2 = {
|
name = hostname;
|
||||||
roles = with roles; [
|
value = cfg;
|
||||||
sonarr
|
}
|
||||||
];
|
) (builtins.readDir ./hosts)
|
||||||
config = {
|
|
||||||
sonarr.domain = "sonarr.${hlConfig.domain}";
|
|
||||||
};
|
|
||||||
stateVersion = "24.05";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
roles,
|
||||||
|
hlConfig,
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
hostname = "base";
|
||||||
|
managed = true;
|
||||||
|
ip = "192.168.10.98";
|
||||||
|
|
||||||
|
roles = with roles; [
|
||||||
|
];
|
||||||
|
config = {
|
||||||
|
};
|
||||||
|
stateVersion = "24.05";
|
||||||
|
}
|
|
@ -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";
|
||||||
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
{
|
{
|
||||||
name = "${hostname}-sonarr";
|
name = "${hostname}-sonarr";
|
||||||
rule = "Host(`${config.sonarr.domain}`)";
|
rule = "Host(`${config.sonarr.domain}`)";
|
||||||
target = "http://${hostname}.lan:8989";
|
target = "http://${config.ip}:8989";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue