also refactor nixos modules
This commit is contained in:
parent
2471562583
commit
b37c5c0cbd
44 changed files with 10 additions and 2 deletions
|
|
@ -1,47 +0,0 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) length;
|
||||
inherit (lib) mkIf mkEnableOption mkOption types attrNames attrsToList listToAttrs;
|
||||
|
||||
cfg = config.sneeuwvlok.services.networking.wireguard;
|
||||
hasPeers = (cfg.peer |> attrNames |> length) > 0;
|
||||
in {
|
||||
options.sneeuwvlok.services.networking.wireguard = {
|
||||
enable = mkEnableOption "enable wireguard" // {default = true;};
|
||||
|
||||
peer = mkOption {
|
||||
type = types.attrsOf (types.submodule {
|
||||
options = {
|
||||
port = mkOption {
|
||||
type = types.port;
|
||||
description = '''';
|
||||
};
|
||||
|
||||
address = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
description = '''';
|
||||
};
|
||||
};
|
||||
});
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf (cfg.enable && hasPeers) {
|
||||
# networking.firewall.allowedUDPPorts = cfg.peer |> lib.attrValues |> lib.map (p: p.port);
|
||||
# networking.wq-quick = {
|
||||
# # enable = cfg.enable;
|
||||
|
||||
# interfaces =
|
||||
# cfg.peer
|
||||
# |> attrsToList
|
||||
# |> imap0 (i: { name, value }: (namevaluepair "wg${i}" (value // {})))
|
||||
# |> listToAttrs;
|
||||
# };
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue