Make bitcoin rpcuser and pass configurable

This commit is contained in:
Jonas Nick 2018-11-22 23:06:41 +00:00
parent 668d66085a
commit 83eabcf952
2 changed files with 17 additions and 3 deletions

View File

@ -7,14 +7,14 @@ let
home = "/var/lib/bitcoin"; home = "/var/lib/bitcoin";
configFile = pkgs.writeText "bitcoin.conf" '' configFile = pkgs.writeText "bitcoin.conf" ''
listen=${if cfg.listen then "1" else "0"} listen=${if cfg.listen then "1" else "0"}
prune=1001 prune=2000
assumevalid=0000000000000000000726d186d6298b5054b9a5c49639752294b322a305d240 assumevalid=0000000000000000000726d186d6298b5054b9a5c49639752294b322a305d240
${optionalString (cfg.proxy != null) "proxy=${cfg.proxy}"} ${optionalString (cfg.proxy != null) "proxy=${cfg.proxy}"}
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 ${optionalString (cfg.rpcuser != null) "rpcuser=${cfg.rpcuser}"}
rpcpassword=bar ${optionalString (cfg.rpcpassword != null) "rpcuser=${cfg.rpcpassword}"}
''; '';
in { in {
options.services.bitcoin = { options.services.bitcoin = {
@ -44,6 +44,16 @@ in {
default = null; default = null;
description = "Override the default port on which to listen for connections."; description = "Override the default port on which to listen for connections.";
}; };
rpcuser = mkOption {
type = types.nullOr types.string;
default = null;
description = "Set bitcoin RPC user";
};
rpcpassword = mkOption {
type = types.nullOr types.string;
default = null;
description = "Set bitcoin RPC password";
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
users.users.bitcoin = { users.users.bitcoin = {

View File

@ -38,9 +38,13 @@ in {
services.bitcoin.listen = true; services.bitcoin.listen = true;
services.bitcoin.proxy = config.services.tor.client.socksListenAddress; services.bitcoin.proxy = config.services.tor.client.socksListenAddress;
services.bitcoin.port = 8333; services.bitcoin.port = 8333;
services.bitcoin.rpcuser = "bitcoinrpc";
services.bitcoin.rpcpassword = "bitcoinrpc";
# clightning # clightning
services.clightning.enable = true; services.clightning.enable = true;
services.clightning.bitcoin-rpcuser = config.services.bitcoin.rpcuser;
services.clightning.bitcoin-rpcpassword = config.services.bitcoin.rpcpassword;
# nodeinfo # nodeinfo
systemd.services.nodeinfo = { systemd.services.nodeinfo = {