From aec819db819088f42ea7f7116c2b3e441f52bbb1 Mon Sep 17 00:00:00 2001 From: Jonas Nick Date: Thu, 22 Nov 2018 18:32:26 +0000 Subject: [PATCH] add clightning --- configuration.nix | 12 +++++++----- modules/bitcoind.nix | 4 ++-- modules/nixbitcoin.nix | 24 ++++++++++++++++++++---- pkgs/nodeinfo.sh | 1 + 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/configuration.nix b/configuration.nix index 0fd3b5c..84afa82 100644 --- a/configuration.nix +++ b/configuration.nix @@ -11,16 +11,20 @@ in { imports = [ - ./modules/bitcoind.nix - ./modules/tor.nix ./modules/nixbitcoin.nix ]; + # TODO: does that destroy the channels symlink? + # turn off binary cache by passing the empty list + #nix.binaryCaches = []; + networking.hostName = "nix-bitcoin"; # Define your hostname. time.timeZone = "UTC"; environment.systemPackages = with pkgs; [ - wget vim tmux git nginx nodeinfo + vim tmux clightning bitcoin + nodeinfo + jq ]; nixpkgs.config.packageOverrides = pkgs: { inherit nodeinfo; @@ -45,8 +49,6 @@ in { services.nixbitcoin.enable = true; - # turn off binary cache by passing the empty list - nix.binaryCaches = []; # Configure network proxy if necessary # networking.proxy.default = "http://user:password@proxy:port/"; diff --git a/modules/bitcoind.nix b/modules/bitcoind.nix index 25bbf1a..459e101 100644 --- a/modules/bitcoind.nix +++ b/modules/bitcoind.nix @@ -13,6 +13,8 @@ let addnode=ecoc5q34tmbq54wl.onion discover=0 ${optionalString (cfg.port != null) "port=${toString cfg.port}"} + rpcuser=foo + rpcpassword=bar ''; in { options.services.bitcoin = { @@ -40,8 +42,6 @@ in { port = mkOption { type = types.nullOr types.ints.u16; default = null; -# type = types.int; - #default = 8333; description = "Override the default port on which to listen for connections."; }; diff --git a/modules/nixbitcoin.nix b/modules/nixbitcoin.nix index e2cb13c..8e1e48d 100644 --- a/modules/nixbitcoin.nix +++ b/modules/nixbitcoin.nix @@ -5,6 +5,13 @@ with lib; let cfg = config.services.nixbitcoin; in { + imports = + [ + ./bitcoind.nix + ./tor.nix + ./clightning.nix + ]; + options.services.nixbitcoin = { enable = mkOption { type = types.bool; @@ -16,21 +23,30 @@ in { }; config = mkIf cfg.enable { - services.bitcoin.enable = true; - services.bitcoin.listen = true; + # Tor services.tor.enable = true; services.tor.client.enable = true; - services.bitcoin.proxy = config.services.tor.client.socksListenAddress; - services.bitcoin.port = 8333; services.tor.hiddenServices.bitcoind = { map = [{ port = config.services.bitcoin.port; }]; version = 3; }; + + # bitcoin + services.bitcoin.enable = true; + services.bitcoin.listen = true; + services.bitcoin.proxy = config.services.tor.client.socksListenAddress; + services.bitcoin.port = 8333; + + # clightning + services.clightning.enable = true; + + # nodeinfo systemd.services.nodeinfo = { description = "Get node info"; wantedBy = [ "multi-user.target" ]; + path = [ pkgs.clightning pkgs.jq pkgs.sudo ]; serviceConfig = { ExecStart = "${pkgs.bash}/bin/bash -c ${pkgs.nodeinfo}/bin/nodeinfo"; user = "root"; diff --git a/pkgs/nodeinfo.sh b/pkgs/nodeinfo.sh index b404356..16a298c 100644 --- a/pkgs/nodeinfo.sh +++ b/pkgs/nodeinfo.sh @@ -4,5 +4,6 @@ rm -f $OUTFILE { echo \{ echo " bitcoind_onion = \"$(cat /var/lib/tor/onion/bitcoind/hostname)\";" + echo " clightning_id = \"$(sudo -u clightning lightning-cli getinfo | jq -r '.id')\";" echo \} } > $OUTFILE