1
0
Fork 0

Fix small syntax issues and describe options

This commit is contained in:
clerie 2021-01-10 22:26:57 +01:00
parent 337f5824f0
commit 040b71b356
1 changed files with 11 additions and 5 deletions

View File

@ -1,11 +1,11 @@
{ config, lib, ... }:
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.clerie.gre-tunnel;
generateInterfaceUnit = isIPv6: name: tunnel:
generateInterfaceUnit = isIPv6: (name: tunnel:
nameValuePair "gre-tunnel-${name}" {
description = "GRE Tunnel - ${name}";
requires = [ "network-online.target" ];
@ -32,30 +32,36 @@ let
ip tunnel del ${name}
${tunnel.postShutdown}
'';
};
});
checkOpts = { config, ... }@moduleAttrs: {
options = {
remote = mkOption {
type = types.str;
description = "Address of reciever.";
};
local = mkOption {
type = types.str;
description = "Address our packets originate from.";
};
address = mkOption {
type = types.str;
description = "Our address in this tunnel.";
};
preSetup = mkOption {
type = types.str;
default = "";
description = "Commands called at the start of the interface setup.";
};
postSetup = mkOption {
type = types.str;
default = "";
description = "Commands called at the end of the interface setup.";
};
postShutdown = mkOption {
type = types.str;
default = "";
description = "Commands called after shutting down the interface.";
};
};
};
@ -77,7 +83,7 @@ in {
config = mkIf cfg.enable {
systemd.services =
(mapAttrsToList (generateInterfaceUnit false) cfg.ipv4)
++ (mapAttrsToList (generateInterfaceUnit true) cfg.ipv6);
(mapAttrs' (generateInterfaceUnit false) cfg.ipv4)
// (mapAttrs' (generateInterfaceUnit true) cfg.ipv6);
};
}