diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/default.nix | 1 | ||||
| -rw-r--r-- | lib/eval-source.nix | 3 | ||||
| -rw-r--r-- | lib/impure.nix | 3 | ||||
| -rw-r--r-- | lib/pure.nix | 4 | ||||
| -rw-r--r-- | lib/types.nix | 24 |
5 files changed, 27 insertions, 8 deletions
diff --git a/lib/default.nix b/lib/default.nix deleted file mode 100644 index f9f2f1579..000000000 --- a/lib/default.nix +++ /dev/null @@ -1 +0,0 @@ -import ./impure.nix diff --git a/lib/eval-source.nix b/lib/eval-source.nix index ff853185b..93320a218 100644 --- a/lib/eval-source.nix +++ b/lib/eval-source.nix @@ -1,4 +1,5 @@ -with import <stockholm/lib>; +{ lib }: +with lib; let eval = _file: source: evalModules { modules = singleton { diff --git a/lib/impure.nix b/lib/impure.nix deleted file mode 100644 index 3f95c375f..000000000 --- a/lib/impure.nix +++ /dev/null @@ -1,3 +0,0 @@ -import ./pure.nix { - lib = import <nixpkgs/lib>; -} diff --git a/lib/pure.nix b/lib/pure.nix index 3fe51cd54..6b5f229e6 100644 --- a/lib/pure.nix +++ b/lib/pure.nix @@ -9,7 +9,7 @@ let }; in filterAttrsRecursive (name: _: !hasPrefix "_" name) eval.config; - evalSource = import ./eval-source.nix; + evalSource = import ./eval-source.nix { lib = stockholm.lib; }; evalSubmodule = submodule: modules: let prefix = ["evalSubmodule"]; @@ -37,7 +37,7 @@ let eq = x: y: x == y; ne = x: y: x != y; - mod = x: y: x - y * (x / y); + #mod = x: y: x - y * (x / y); on = b: u: x: y: b (u x) (u y); diff --git a/lib/types.nix b/lib/types.nix index ad8421b18..f0165c523 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -1,5 +1,4 @@ { lib, ... }: - let inherit (lib) all any attrNames concatMapStringsSep concatStringsSep const filter flip @@ -198,9 +197,32 @@ rec { }; tinc = mkOption { type = let net = config; in nullOr (submodule ({ config, ... }: { + config = { + config = + #assert (with builtins; trace "xxxxxx ${toJSON config.subnets}" true); + concatStringsSep "\n" ( + (optionals (net.via != null) + (map (a: "Address = ${a} ${toString config.port}") net.via.addrs)) + ++ + (map (a: "Subnet = ${a}") config.subnets) + ++ + (map (a: "Subnet = ${a}") net.addrs) + ++ + [config.extraConfig] + ++ + [config.pubkey] + ++ + optional (config.pubkey_ed25519 != null) '' + Ed25519PublicKey = ${config.pubkey_ed25519} + '' + ++ + optional (config.weight != null) "Weight = ${toString config.weight}" + ); + }; options = { config = mkOption { type = str; + # TODO: readOnly = true; default = concatStringsSep "\n" ( (optionals (net.via != null) (map (a: "Address = ${a} ${toString config.port}") net.via.addrs)) |
