Refactor Wireguard to make it use sisko
as server
This commit is contained in:
parent
0d3c1aae46
commit
f05c12545a
29 changed files with 430 additions and 418 deletions
|
@ -8,7 +8,9 @@
|
|||
config,
|
||||
inputs,
|
||||
...
|
||||
}: {
|
||||
}: let
|
||||
cfg = config.fleet;
|
||||
in {
|
||||
options.fleet = {
|
||||
hosts = lib.mkOption {
|
||||
description = "Host configuration";
|
||||
|
@ -24,6 +26,16 @@
|
|||
type = lib.types.str;
|
||||
default = "x86_64-linux";
|
||||
};
|
||||
vpn = {
|
||||
ip = lib.mkOption {
|
||||
description = "Wireguard VPN ip";
|
||||
type = lib.types.str;
|
||||
};
|
||||
publicKey = lib.mkOption {
|
||||
description = "Wireguard public key";
|
||||
type = lib.types.str;
|
||||
};
|
||||
};
|
||||
secrets = lib.mkOption {
|
||||
description = "List of secrets names in the `secrets` folder";
|
||||
type = lib.types.attrsOf (lib.types.submodule ({name, ...}: {
|
||||
|
@ -84,10 +96,25 @@
|
|||
[
|
||||
nur.overlay
|
||||
]
|
||||
++ config.fleet.overlays;
|
||||
++ cfg.overlays;
|
||||
}));
|
||||
default = {};
|
||||
};
|
||||
vpnExtra = lib.mkOption {
|
||||
type = lib.types.attrsOf (lib.types.submodule {
|
||||
options = {
|
||||
ip = lib.mkOption {
|
||||
description = "Wireguard VPN ip";
|
||||
type = lib.types.str;
|
||||
};
|
||||
publicKey = lib.mkOption {
|
||||
description = "Wireguard public key";
|
||||
type = lib.types.str;
|
||||
};
|
||||
};
|
||||
});
|
||||
default = {};
|
||||
};
|
||||
_mkNixosConfiguration = lib.mkOption {
|
||||
description = "Function returning a proper NixOS configuration";
|
||||
type = lib.types.functionTo (lib.types.functionTo lib.types.attrs); # TODO improve this type
|
||||
|
@ -100,12 +127,6 @@
|
|||
({lib, ...}: {
|
||||
networking.hostName = lib.mkForce hostname;
|
||||
nixpkgs.overlays = config.overlays;
|
||||
networking.hosts =
|
||||
lib.mapAttrs' (hostname: ip: {
|
||||
name = ip;
|
||||
value = ["${hostname}.fleet"];
|
||||
})
|
||||
(import "${self}/lib").ips;
|
||||
})
|
||||
"${self.outPath}/hosts/${hostname}"
|
||||
]
|
||||
|
@ -156,6 +177,7 @@
|
|||
fleetModules = builtins.map (moduleName: "${self.outPath}/modules/${moduleName}");
|
||||
fleetHmModules = builtins.map (moduleName: "${self.outPath}/hmModules/${moduleName}");
|
||||
fleetFlake = self;
|
||||
vpn = cfg.vpnExtra // (lib.mapAttrs (_: host: host.vpn) cfg.hosts);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue