2021-12-07 06:28:12 -08:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.bitcoind;
|
|
|
|
secretsDir = config.nix-bitcoin.secretsDir;
|
|
|
|
in {
|
|
|
|
services.bitcoind = {
|
2023-01-20 04:45:09 -08:00
|
|
|
# Make the local bitcoin-cli work with the remote node.
|
|
|
|
# Without this, bitcoin-cli would try to use the .cookie file in the local
|
|
|
|
# bitcoind data dir for authorization, which doesn't exist.
|
2021-12-07 06:28:12 -08:00
|
|
|
extraConfig = ''
|
|
|
|
rpcuser=${cfg.rpc.users.privileged.name}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.bitcoind = {
|
|
|
|
preStart = lib.mkAfter ''
|
2022-07-15 14:40:16 -07:00
|
|
|
echo "rpcpassword=$(cat ${secretsDir}/bitcoin-rpcpassword-privileged)" >> '${cfg.dataDir}/bitcoin.conf'
|
2021-12-07 06:28:12 -08:00
|
|
|
'';
|
|
|
|
postStart = lib.mkForce "";
|
|
|
|
serviceConfig = {
|
|
|
|
Type = lib.mkForce "oneshot";
|
|
|
|
ExecStart = lib.mkForce "${pkgs.coreutils}/bin/true";
|
|
|
|
RemainAfterExit = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|