2018-11-19 15:09:57 -08:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
2018-11-20 14:21:45 -08:00
|
|
|
cfg = config.services.nixbitcoin;
|
2018-11-22 15:51:16 -08:00
|
|
|
secrets = import ../load-secrets.nix;
|
2018-11-19 15:09:57 -08:00
|
|
|
in {
|
2018-11-22 10:32:26 -08:00
|
|
|
imports =
|
|
|
|
[
|
|
|
|
./bitcoind.nix
|
|
|
|
./tor.nix
|
|
|
|
./clightning.nix
|
|
|
|
];
|
|
|
|
|
2018-11-20 14:21:45 -08:00
|
|
|
options.services.nixbitcoin = {
|
2018-11-19 15:09:57 -08:00
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
2018-11-20 14:21:45 -08:00
|
|
|
If enabled, the nix-bitcoin service will be installed.
|
2018-11-19 15:09:57 -08:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2018-11-22 10:32:26 -08:00
|
|
|
# Tor
|
2018-11-19 15:09:57 -08:00
|
|
|
services.tor.enable = true;
|
|
|
|
services.tor.client.enable = true;
|
2018-11-19 16:22:16 -08:00
|
|
|
services.tor.hiddenServices.bitcoind = {
|
|
|
|
map = [{
|
2018-11-22 16:46:56 -08:00
|
|
|
port = config.services.bitcoind.port;
|
2018-11-19 16:22:16 -08:00
|
|
|
}];
|
|
|
|
version = 3;
|
2018-11-19 15:09:57 -08:00
|
|
|
};
|
2018-11-22 10:32:26 -08:00
|
|
|
|
2018-11-22 16:46:56 -08:00
|
|
|
# bitcoind
|
|
|
|
services.bitcoind.enable = true;
|
|
|
|
services.bitcoind.listen = true;
|
|
|
|
services.bitcoind.proxy = config.services.tor.client.socksListenAddress;
|
|
|
|
services.bitcoind.port = 8333;
|
|
|
|
services.bitcoind.rpcuser = "bitcoinrpc";
|
|
|
|
services.bitcoind.rpcpassword = secrets.bitcoinrpcpassword;
|
2018-11-22 10:32:26 -08:00
|
|
|
|
|
|
|
# clightning
|
|
|
|
services.clightning.enable = true;
|
2018-11-22 16:46:56 -08:00
|
|
|
services.clightning.bitcoin-rpcuser = config.services.bitcoind.rpcuser;
|
|
|
|
services.clightning.bitcoin-rpcpassword = config.services.bitcoind.rpcpassword;
|
2018-11-22 10:32:26 -08:00
|
|
|
|
|
|
|
# nodeinfo
|
2018-11-20 14:21:45 -08:00
|
|
|
systemd.services.nodeinfo = {
|
|
|
|
description = "Get node info";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2018-11-22 10:32:26 -08:00
|
|
|
path = [ pkgs.clightning pkgs.jq pkgs.sudo ];
|
2018-11-20 14:21:45 -08:00
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pkgs.bash}/bin/bash -c ${pkgs.nodeinfo}/bin/nodeinfo";
|
|
|
|
user = "root";
|
|
|
|
type = "oneshot";
|
|
|
|
};
|
|
|
|
};
|
2018-11-19 16:22:16 -08:00
|
|
|
};
|
2018-11-19 15:09:57 -08:00
|
|
|
}
|