From cf4568d2f5e131a29efaac141fde1ade8e47dd7d Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 20 Feb 2017 22:45:20 +0100 Subject: use submodule properly --- custom/tinc/def.nix | 145 ++++++++++++++++++++++++++-------------------------- 1 file changed, 72 insertions(+), 73 deletions(-) diff --git a/custom/tinc/def.nix b/custom/tinc/def.nix index a3bb00a0..98174eb6 100644 --- a/custom/tinc/def.nix +++ b/custom/tinc/def.nix @@ -6,6 +6,77 @@ let cfg = config.services.customTinc; + networkModule = { + extraConfig = mkOption { + default = '' + PingTimeout = 10 + ''; + type = types.lines; + description = '' + Extra lines to add to the tinc service configuration file. + ''; + }; + + name = mkOption { + default = null; + type = types.nullOr types.str; + description = '' + The name of the node which is used as an identifier when communicating + with the remote nodes in the mesh. If null then the hostname of the system + is used. + ''; + }; + + debugLevel = mkOption { + default = 0; + type = types.addCheck types.int (l: l >= 0 && l <= 5); + description = '' + The amount of debugging information to add to the log. 0 means little + logging while 5 is the most logging. man tincd for + more details. + ''; + }; + + hosts = mkOption { + default = { }; + type = types.loaOf types.lines; + description = '' + The name of the host in the network as well as the configuration for that host. + This name should only contain alphanumerics and underscores. + ''; + }; + + interfaceType = mkOption { + default = "tun"; + type = types.addCheck types.str (n: n == "tun" || n == "tap"); + description = '' + The type of virtual interface used for the network connection + ''; + }; + + interfaceConfig = mkOption { + default = { }; + description = '' + Additional configuration for the generated network interface + ''; + }; + + package = mkOption { + default = pkgs.tinc_pre; + description = '' + The package to use for the tinc daemon's binary. + ''; + }; + + scripts = mkOption { + default = { }; + type = types.loaOf (types.nullOr types.str); + description = '' + Hook scripts + ''; + }; + + }; in { @@ -18,83 +89,11 @@ in networks = mkOption { default = { }; - type = types.loaOf types.submodule; + type = types.loaOf (types.submodule networkModule); description = '' Defines the tinc networks which will be started. Each network invokes a different daemon. ''; - options = { - - extraConfig = mkOption { - default = '' - PingTimeout = 10 - ''; - type = types.lines; - description = '' - Extra lines to add to the tinc service configuration file. - ''; - }; - - name = mkOption { - default = null; - type = types.nullOr types.str; - description = '' - The name of the node which is used as an identifier when communicating - with the remote nodes in the mesh. If null then the hostname of the system - is used. - ''; - }; - - debugLevel = mkOption { - default = 0; - type = types.addCheck types.int (l: l >= 0 && l <= 5); - description = '' - The amount of debugging information to add to the log. 0 means little - logging while 5 is the most logging. man tincd for - more details. - ''; - }; - - hosts = mkOption { - default = { }; - type = types.loaOf types.lines; - description = '' - The name of the host in the network as well as the configuration for that host. - This name should only contain alphanumerics and underscores. - ''; - }; - - interfaceType = mkOption { - default = "tun"; - type = types.addCheck types.str (n: n == "tun" || n == "tap"); - description = '' - The type of virtual interface used for the network connection - ''; - }; - - interfaceConfig = mkOption { - default = { }; - description = '' - Additional configuration for the generated network interface - ''; - }; - - package = mkOption { - default = pkgs.tinc_pre; - description = '' - The package to use for the tinc daemon's binary. - ''; - }; - - scripts = mkOption { - default = { }; - type = types.loaOf (types.nullOr types.str); - description = '' - Hook scripts - ''; - }; - - }; }; }; -- cgit v1.2.3