From 322ba5bfff1dc250b28ee6ccffa33316fbf334ce Mon Sep 17 00:00:00 2001 From: Jonas Nick Date: Tue, 4 Aug 2020 14:11:51 +0000 Subject: [PATCH] Add nix-bitcoin.lib for utility functions and types --- modules/clightning.nix | 2 +- modules/lnd.nix | 2 +- pkgs/default.nix | 2 ++ pkgs/lib.nix | 5 +++++ 4 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 pkgs/lib.nix diff --git a/modules/clightning.nix b/modules/clightning.nix index c70ad23..edc42e9 100644 --- a/modules/clightning.nix +++ b/modules/clightning.nix @@ -46,7 +46,7 @@ in { ''; }; bind-addr = mkOption { - type = types.addCheck types.str (s: builtins.length (builtins.split ":" s) == 1); + type = pkgs.nix-bitcoin.lib.ipv4Address; default = "127.0.0.1"; description = "Set an IP address or UNIX domain socket to listen to"; }; diff --git a/modules/lnd.nix b/modules/lnd.nix index 48446d4..998440f 100644 --- a/modules/lnd.nix +++ b/modules/lnd.nix @@ -47,7 +47,7 @@ in { description = "The data directory for LND."; }; listen = mkOption { - type = types.addCheck types.str (s: builtins.length (builtins.split ":" s) == 1); + type = pkgs.nix-bitcoin.lib.ipv4Address; default = "localhost"; description = "Bind to given address to listen to peer connections"; }; diff --git a/pkgs/default.nix b/pkgs/default.nix index 7986379..7c7adbc 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -14,4 +14,6 @@ lightning-loop = pkgs.callPackage ./lightning-loop { }; pinned = import ./pinned.nix; + + lib = import ./lib.nix { inherit (pkgs) lib; }; } diff --git a/pkgs/lib.nix b/pkgs/lib.nix new file mode 100644 index 0000000..43dbe45 --- /dev/null +++ b/pkgs/lib.nix @@ -0,0 +1,5 @@ +{ lib }: +{ + # An address type that checks that there's no port + ipv4Address = lib.types.addCheck lib.types.str (s: builtins.length (builtins.split ":" s) == 1); +}