electrs: add variable 'bitcoind'
This commit is contained in:
parent
a6dde36b87
commit
a19d3b07c2
|
@ -5,6 +5,7 @@ let
|
||||||
cfg = config.services.electrs;
|
cfg = config.services.electrs;
|
||||||
inherit (config) nix-bitcoin-services;
|
inherit (config) nix-bitcoin-services;
|
||||||
secretsDir = config.nix-bitcoin.secretsDir;
|
secretsDir = config.nix-bitcoin.secretsDir;
|
||||||
|
bitcoind = config.services.bitcoind;
|
||||||
in {
|
in {
|
||||||
options.services.electrs = {
|
options.services.electrs = {
|
||||||
enable = mkEnableOption "electrs";
|
enable = mkEnableOption "electrs";
|
||||||
|
@ -57,7 +58,7 @@ in {
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
assertions = [
|
assertions = [
|
||||||
{ assertion = config.services.bitcoind.prune == 0;
|
{ assertion = bitcoind.prune == 0;
|
||||||
message = "electrs does not support bitcoind pruning.";
|
message = "electrs does not support bitcoind pruning.";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -74,7 +75,7 @@ in {
|
||||||
requires = [ "bitcoind.service" ];
|
requires = [ "bitcoind.service" ];
|
||||||
after = [ "bitcoind.service" ];
|
after = [ "bitcoind.service" ];
|
||||||
preStart = ''
|
preStart = ''
|
||||||
echo "cookie = \"${config.services.bitcoind.rpc.users.public.name}:$(cat ${secretsDir}/bitcoin-rpcpassword-public)\"" \
|
echo "cookie = \"${bitcoind.rpc.users.public.name}:$(cat ${secretsDir}/bitcoin-rpcpassword-public)\"" \
|
||||||
> electrs.toml
|
> electrs.toml
|
||||||
'';
|
'';
|
||||||
serviceConfig = nix-bitcoin-services.defaultHardening // {
|
serviceConfig = nix-bitcoin-services.defaultHardening // {
|
||||||
|
@ -84,7 +85,7 @@ in {
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.nix-bitcoin.electrs}/bin/electrs -vvv \
|
${pkgs.nix-bitcoin.electrs}/bin/electrs -vvv \
|
||||||
${if cfg.high-memory then
|
${if cfg.high-memory then
|
||||||
traceIf (!config.services.bitcoind.dataDirReadableByGroup) ''
|
traceIf (!bitcoind.dataDirReadableByGroup) ''
|
||||||
Warning: For optimal electrs syncing performance, enable services.bitcoind.dataDirReadableByGroup.
|
Warning: For optimal electrs syncing performance, enable services.bitcoind.dataDirReadableByGroup.
|
||||||
Note that this disables wallet support in bitcoind.
|
Note that this disables wallet support in bitcoind.
|
||||||
'' ""
|
'' ""
|
||||||
|
@ -92,7 +93,7 @@ in {
|
||||||
"--jsonrpc-import --index-batch-size=10"
|
"--jsonrpc-import --index-batch-size=10"
|
||||||
} \
|
} \
|
||||||
--db-dir='${cfg.dataDir}' \
|
--db-dir='${cfg.dataDir}' \
|
||||||
--daemon-dir='${config.services.bitcoind.dataDir}' \
|
--daemon-dir='${bitcoind.dataDir}' \
|
||||||
--electrum-rpc-addr=${toString cfg.address}:${toString cfg.port} \
|
--electrum-rpc-addr=${toString cfg.address}:${toString cfg.port} \
|
||||||
--daemon-rpc-addr=${toString cfg.daemonrpc} \
|
--daemon-rpc-addr=${toString cfg.daemonrpc} \
|
||||||
${cfg.extraArgs}
|
${cfg.extraArgs}
|
||||||
|
@ -101,7 +102,7 @@ in {
|
||||||
Group = cfg.group;
|
Group = cfg.group;
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
RestartSec = "10s";
|
RestartSec = "10s";
|
||||||
ReadWritePaths = "${cfg.dataDir} ${if cfg.high-memory then "${config.services.bitcoind.dataDir}" else ""}";
|
ReadWritePaths = "${cfg.dataDir} ${if cfg.high-memory then "${bitcoind.dataDir}" else ""}";
|
||||||
} // (if cfg.enforceTor
|
} // (if cfg.enforceTor
|
||||||
then nix-bitcoin-services.allowTor
|
then nix-bitcoin-services.allowTor
|
||||||
else nix-bitcoin-services.allowAnyIP
|
else nix-bitcoin-services.allowAnyIP
|
||||||
|
|
Loading…
Reference in New Issue
Block a user