Incorproate PR comments, correct erroneous description in clightning module, add electrs module, add electrs package, add electrs to nix-bitcoin.nix, add electrs to modules/nix-bitcoin.nix
This commit is contained in:
parent
bb07fa9589
commit
9ada1d32f3
5 changed files with 111 additions and 2 deletions
|
|
@ -34,7 +34,7 @@ in {
|
|||
dataDir = mkOption {
|
||||
type = types.path;
|
||||
default = "/var/lib/clightning";
|
||||
description = "The data directory for bitcoind.";
|
||||
description = "The data directory for clightning.";
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
60
modules/electrs.nix
Normal file
60
modules/electrs.nix
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.electrs;
|
||||
in {
|
||||
options.services.electrs = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
If enabled, the electrs service will be installed.
|
||||
'';
|
||||
};
|
||||
dataDir = mkOption {
|
||||
type = types.path;
|
||||
default = "/var/lib/electrs";
|
||||
description = "The data directory for electrs.";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
users.users.electrs = {
|
||||
description = "electrs User";
|
||||
group = "electrs";
|
||||
extraGroups = [ "bitcoinrpc" "keys" ];
|
||||
home = cfg.dataDir;
|
||||
};
|
||||
users.groups.electrs = {
|
||||
name = "electrs";
|
||||
};
|
||||
|
||||
systemd.services.electrs = {
|
||||
description = "Run electrs";
|
||||
wantedBy = [ "muli-user.target" ];
|
||||
requires = [ "bitcoind.service" ];
|
||||
after = [ "bitcoind.service" ];
|
||||
# create shell script to start up electrs safely with password parameter
|
||||
preStart = ''
|
||||
mkdir -m 0770 -p ${cfg.dataDir}
|
||||
chown 'electrs:electrs' ${cfg.dataDir}
|
||||
echo "${pkgs.electrs}/bin/electrs -vvv --timestamp --db-dir ${cfg.dataDir} --daemon-dir /var/lib/bitcoind --cookie=${config.services.bitcoind.rpcuser}:$(cat /secrets/bitcoin-rpcpassword)" > /var/lib/electrs/startscript.sh
|
||||
chown -R 'electrs:electrs' ${cfg.dataDir}
|
||||
chmod u+x ${cfg.dataDir}/startscript.sh
|
||||
'';
|
||||
serviceConfig = {
|
||||
PermissionsStartOnly = "true";
|
||||
ExecStart = "${pkgs.bash}/bin/bash ${cfg.dataDir}/startscript.sh";
|
||||
User = "electrs";
|
||||
Restart = "on-failure";
|
||||
RestartSec = "10s";
|
||||
PrivateTmp = "true";
|
||||
ProtectSystem = "full";
|
||||
NoNewPrivileges = "true";
|
||||
PrivateDevices = "true";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -16,6 +16,7 @@ let
|
|||
lightning-charge.package
|
||||
nanopos.package
|
||||
spark-wallet.package
|
||||
electrs
|
||||
nodejs-8_x
|
||||
nginx
|
||||
];
|
||||
|
|
@ -38,6 +39,7 @@ in {
|
|||
./nix-bitcoin-webindex.nix
|
||||
./liquid.nix
|
||||
./spark-wallet.nix
|
||||
./electrs.nix
|
||||
];
|
||||
|
||||
options.services.nix-bitcoin = {
|
||||
|
|
@ -83,7 +85,7 @@ in {
|
|||
addnode=ecoc5q34tmbq54wl.onion
|
||||
discover=0
|
||||
'';
|
||||
services.bitcoind.prune = 2000;
|
||||
services.bitcoind.prune = if (cfg.modules == "minimal") then 2000 else 0;
|
||||
services.bitcoind.dbCache = 1000;
|
||||
services.tor.hiddenServices.bitcoind = {
|
||||
map = [{
|
||||
|
|
@ -146,6 +148,7 @@ in {
|
|||
services.nix-bitcoin-webindex.enable = cfg.modules == "all";
|
||||
services.clightning.autolisten = cfg.modules == "all";
|
||||
services.spark-wallet.enable = cfg.modules == "all";
|
||||
services.electrs.enable = cfg.modules == "all";
|
||||
services.tor.hiddenServices.spark-wallet = {
|
||||
map = [{
|
||||
port = 80; toPort = 9737;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue