Add non managed hosts
parent
ae04786633
commit
a8e15efa13
|
@ -1,4 +1,7 @@
|
|||
{
|
||||
domain = "staging.kallestruik.nl";
|
||||
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 =
|
||||
{ self, nixpkgs, ... }@inputs:
|
||||
let
|
||||
lib = nixpkgs.lib;
|
||||
outputs = self.outputs;
|
||||
utils = import ./utils.nix { inherit inputs; };
|
||||
|
||||
homelabConfig = import ./config.nix;
|
||||
utils = import ./utils.nix { inherit inputs homelabConfig; };
|
||||
|
||||
roles = import ./roles { inherit utils; };
|
||||
hosts = import ./hosts.nix {
|
||||
inherit homelabConfig roles;
|
||||
lib = nixpkgs.lib;
|
||||
inherit
|
||||
homelabConfig
|
||||
roles
|
||||
utils
|
||||
lib
|
||||
;
|
||||
};
|
||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||
in
|
||||
|
@ -51,7 +57,7 @@
|
|||
(utils.mkSystem {
|
||||
hostConfig = value;
|
||||
})
|
||||
) hosts);
|
||||
) (lib.attrsets.filterAttrs (_: host: host.managed) hosts));
|
||||
nixosConfigurations = {
|
||||
template = nixpkgs.lib.nixosSystem {
|
||||
specialArgs = { inherit inputs; };
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
roles,
|
||||
homelabConfig,
|
||||
lib,
|
||||
utils,
|
||||
...
|
||||
}:
|
||||
lib.attrsets.mapAttrs' (
|
||||
|
@ -15,6 +16,6 @@ lib.attrsets.mapAttrs' (
|
|||
in
|
||||
{
|
||||
name = hostname;
|
||||
value = cfg;
|
||||
value = utils.mkHost cfg;
|
||||
}
|
||||
) (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,
|
||||
...
|
||||
}:
|
||||
{
|
||||
sonarr = utils.mkRole (import ./sonarr.nix);
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
config =
|
||||
let
|
||||
cfg = config.traefik;
|
||||
routes = concatMap (
|
||||
roleRoutes = concatMap (
|
||||
hostname:
|
||||
concatMap (
|
||||
role:
|
||||
|
@ -33,6 +33,8 @@
|
|||
}
|
||||
) hosts.${hostname}.roles
|
||||
) (builtins.attrNames hosts);
|
||||
hostRoutes = concatMap (hostname: hosts.${hostname}.traefikRoutes) (builtins.attrNames hosts);
|
||||
routes = roleRoutes ++ hostRoutes;
|
||||
in
|
||||
{
|
||||
networking.firewall.allowedTCPPorts = [
|
||||
|
|
17
utils.nix
17
utils.nix
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
inputs,
|
||||
homelabConfig,
|
||||
...
|
||||
}:
|
||||
{
|
||||
|
@ -32,9 +33,9 @@
|
|||
prefixLength = 24;
|
||||
}
|
||||
];
|
||||
nameservers = [ "192.168.10.1" ];
|
||||
nameservers = homelabConfig.defaultDNS;
|
||||
defaultGateway = {
|
||||
address = "192.168.10.1";
|
||||
address = homelabConfig.defaultGateway;
|
||||
interface = "eth0";
|
||||
};
|
||||
};
|
||||
|
@ -49,4 +50,16 @@
|
|||
inherit (cfg) name description nixosModule;
|
||||
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