Different hosts config layout + use IPs
parent
95cbc98ee3
commit
35bfc55356
|
@ -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;
|
||||
};
|
||||
|
|
45
hosts.nix
45
hosts.nix
|
@ -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)
|
||||
|
|
|
@ -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";
|
||||
rule = "Host(`${config.sonarr.domain}`)";
|
||||
target = "http://${hostname}.lan:8989";
|
||||
target = "http://${config.ip}:8989";
|
||||
}
|
||||
];
|
||||
|
||||
|
|
Loading…
Reference in New Issue