Add non managed hosts
parent
ae04786633
commit
a8e15efa13
|
@ -1,4 +1,7 @@
|
||||||
{
|
{
|
||||||
domain = "staging.kallestruik.nl";
|
domain = "staging.kallestruik.nl";
|
||||||
shortDomain = "khs.li";
|
shortDomain = "khs.li";
|
||||||
|
# Networking
|
||||||
|
defaultDNS = [ "192.168.10.1" ];
|
||||||
|
defaultGateway = "192.168.10.1";
|
||||||
}
|
}
|
||||||
|
|
14
flake.nix
14
flake.nix
|
@ -13,14 +13,20 @@
|
||||||
outputs =
|
outputs =
|
||||||
{ self, nixpkgs, ... }@inputs:
|
{ self, nixpkgs, ... }@inputs:
|
||||||
let
|
let
|
||||||
|
lib = nixpkgs.lib;
|
||||||
outputs = self.outputs;
|
outputs = self.outputs;
|
||||||
utils = import ./utils.nix { inherit inputs; };
|
|
||||||
|
|
||||||
homelabConfig = import ./config.nix;
|
homelabConfig = import ./config.nix;
|
||||||
|
utils = import ./utils.nix { inherit inputs homelabConfig; };
|
||||||
|
|
||||||
roles = import ./roles { inherit utils; };
|
roles = import ./roles { inherit utils; };
|
||||||
hosts = import ./hosts.nix {
|
hosts = import ./hosts.nix {
|
||||||
inherit homelabConfig roles;
|
inherit
|
||||||
lib = nixpkgs.lib;
|
homelabConfig
|
||||||
|
roles
|
||||||
|
utils
|
||||||
|
lib
|
||||||
|
;
|
||||||
};
|
};
|
||||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||||
in
|
in
|
||||||
|
@ -51,7 +57,7 @@
|
||||||
(utils.mkSystem {
|
(utils.mkSystem {
|
||||||
hostConfig = value;
|
hostConfig = value;
|
||||||
})
|
})
|
||||||
) hosts);
|
) (lib.attrsets.filterAttrs (_: host: host.managed) hosts));
|
||||||
nixosConfigurations = {
|
nixosConfigurations = {
|
||||||
template = nixpkgs.lib.nixosSystem {
|
template = nixpkgs.lib.nixosSystem {
|
||||||
specialArgs = { inherit inputs; };
|
specialArgs = { inherit inputs; };
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
roles,
|
roles,
|
||||||
homelabConfig,
|
homelabConfig,
|
||||||
lib,
|
lib,
|
||||||
|
utils,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
lib.attrsets.mapAttrs' (
|
lib.attrsets.mapAttrs' (
|
||||||
|
@ -15,6 +16,6 @@ lib.attrsets.mapAttrs' (
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
name = hostname;
|
name = hostname;
|
||||||
value = cfg;
|
value = utils.mkHost cfg;
|
||||||
}
|
}
|
||||||
) (builtins.readDir ./hosts)
|
) (builtins.readDir ./hosts)
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
hlConfig,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
rec {
|
||||||
|
hostname = "homeassistant";
|
||||||
|
managed = false;
|
||||||
|
ip = "192.168.10.98";
|
||||||
|
|
||||||
|
traefikRoutes = [
|
||||||
|
{
|
||||||
|
name = "${hostname}";
|
||||||
|
rule = "Host(`home.${hlConfig.domain}`)";
|
||||||
|
target = "http://${ip}:8123";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
utils,
|
utils,
|
||||||
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
sonarr = utils.mkRole (import ./sonarr.nix);
|
sonarr = utils.mkRole (import ./sonarr.nix);
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
config =
|
config =
|
||||||
let
|
let
|
||||||
cfg = config.traefik;
|
cfg = config.traefik;
|
||||||
routes = concatMap (
|
roleRoutes = concatMap (
|
||||||
hostname:
|
hostname:
|
||||||
concatMap (
|
concatMap (
|
||||||
role:
|
role:
|
||||||
|
@ -33,6 +33,8 @@
|
||||||
}
|
}
|
||||||
) hosts.${hostname}.roles
|
) hosts.${hostname}.roles
|
||||||
) (builtins.attrNames hosts);
|
) (builtins.attrNames hosts);
|
||||||
|
hostRoutes = concatMap (hostname: hosts.${hostname}.traefikRoutes) (builtins.attrNames hosts);
|
||||||
|
routes = roleRoutes ++ hostRoutes;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
networking.firewall.allowedTCPPorts = [
|
networking.firewall.allowedTCPPorts = [
|
||||||
|
|
17
utils.nix
17
utils.nix
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
inputs,
|
inputs,
|
||||||
|
homelabConfig,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
|
@ -32,9 +33,9 @@
|
||||||
prefixLength = 24;
|
prefixLength = 24;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
nameservers = [ "192.168.10.1" ];
|
nameservers = homelabConfig.defaultDNS;
|
||||||
defaultGateway = {
|
defaultGateway = {
|
||||||
address = "192.168.10.1";
|
address = homelabConfig.defaultGateway;
|
||||||
interface = "eth0";
|
interface = "eth0";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -49,4 +50,16 @@
|
||||||
inherit (cfg) name description nixosModule;
|
inherit (cfg) name description nixosModule;
|
||||||
traefikRoutes = cfg.traefikRoutes or ({ ... }: [ ]);
|
traefikRoutes = cfg.traefikRoutes or ({ ... }: [ ]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mkHost = cfg: {
|
||||||
|
inherit (cfg)
|
||||||
|
hostname
|
||||||
|
managed
|
||||||
|
ip
|
||||||
|
stateVersion
|
||||||
|
;
|
||||||
|
traefikRoutes = cfg.traefikRoutes or [ ];
|
||||||
|
roles = cfg.roles or [ ];
|
||||||
|
config = cfg.config or { };
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue