nix-bitcoin/modules/nixbitcoin.nix

58 lines
1.2 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
with lib;
let
2018-11-20 14:21:45 -08:00
cfg = config.services.nixbitcoin;
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 = {
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.
'';
};
};
config = mkIf cfg.enable {
2018-11-22 10:32:26 -08:00
# Tor
services.tor.enable = true;
services.tor.client.enable = true;
2018-11-19 16:22:16 -08:00
services.tor.hiddenServices.bitcoind = {
map = [{
port = config.services.bitcoin.port;
}];
version = 3;
};
2018-11-22 10:32:26 -08:00
# 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
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
};
}