add clightning

This commit is contained in:
Jonas Nick 2018-11-22 18:32:26 +00:00
parent 63e2c6d270
commit aec819db81
4 changed files with 30 additions and 11 deletions

View File

@ -11,16 +11,20 @@ in {
imports = imports =
[ [
./modules/bitcoind.nix
./modules/tor.nix
./modules/nixbitcoin.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. networking.hostName = "nix-bitcoin"; # Define your hostname.
time.timeZone = "UTC"; time.timeZone = "UTC";
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
wget vim tmux git nginx nodeinfo vim tmux clightning bitcoin
nodeinfo
jq
]; ];
nixpkgs.config.packageOverrides = pkgs: { nixpkgs.config.packageOverrides = pkgs: {
inherit nodeinfo; inherit nodeinfo;
@ -45,8 +49,6 @@ in {
services.nixbitcoin.enable = true; services.nixbitcoin.enable = true;
# turn off binary cache by passing the empty list
nix.binaryCaches = [];
# Configure network proxy if necessary # Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/"; # networking.proxy.default = "http://user:password@proxy:port/";

View File

@ -13,6 +13,8 @@ let
addnode=ecoc5q34tmbq54wl.onion addnode=ecoc5q34tmbq54wl.onion
discover=0 discover=0
${optionalString (cfg.port != null) "port=${toString cfg.port}"} ${optionalString (cfg.port != null) "port=${toString cfg.port}"}
rpcuser=foo
rpcpassword=bar
''; '';
in { in {
options.services.bitcoin = { options.services.bitcoin = {
@ -40,8 +42,6 @@ in {
port = mkOption { port = mkOption {
type = types.nullOr types.ints.u16; type = types.nullOr types.ints.u16;
default = null; default = null;
# type = types.int;
#default = 8333;
description = "Override the default port on which to listen for connections."; description = "Override the default port on which to listen for connections.";
}; };

View File

@ -5,6 +5,13 @@ with lib;
let let
cfg = config.services.nixbitcoin; cfg = config.services.nixbitcoin;
in { in {
imports =
[
./bitcoind.nix
./tor.nix
./clightning.nix
];
options.services.nixbitcoin = { options.services.nixbitcoin = {
enable = mkOption { enable = mkOption {
type = types.bool; type = types.bool;
@ -16,21 +23,30 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
services.bitcoin.enable = true; # Tor
services.bitcoin.listen = true;
services.tor.enable = true; services.tor.enable = true;
services.tor.client.enable = true; services.tor.client.enable = true;
services.bitcoin.proxy = config.services.tor.client.socksListenAddress;
services.bitcoin.port = 8333;
services.tor.hiddenServices.bitcoind = { services.tor.hiddenServices.bitcoind = {
map = [{ map = [{
port = config.services.bitcoin.port; port = config.services.bitcoin.port;
}]; }];
version = 3; 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 = { systemd.services.nodeinfo = {
description = "Get node info"; description = "Get node info";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
path = [ pkgs.clightning pkgs.jq pkgs.sudo ];
serviceConfig = { serviceConfig = {
ExecStart = "${pkgs.bash}/bin/bash -c ${pkgs.nodeinfo}/bin/nodeinfo"; ExecStart = "${pkgs.bash}/bin/bash -c ${pkgs.nodeinfo}/bin/nodeinfo";
user = "root"; user = "root";

View File

@ -4,5 +4,6 @@ rm -f $OUTFILE
{ {
echo \{ echo \{
echo " bitcoind_onion = \"$(cat /var/lib/tor/onion/bitcoind/hostname)\";" echo " bitcoind_onion = \"$(cat /var/lib/tor/onion/bitcoind/hostname)\";"
echo " clightning_id = \"$(sudo -u clightning lightning-cli getinfo | jq -r '.id')\";"
echo \} echo \}
} > $OUTFILE } > $OUTFILE