move systemPackages definitions to services

These are generally useful and shouldn't be limited to secure-node.nix.

Also, only add the hardware-wallets group when hardware wallets are enabled.
This commit is contained in:
Erik Arvstedt 2020-04-07 22:47:45 +02:00
parent 6c22e13b7f
commit 37b2faf63c
No known key found for this signature in database
GPG Key ID: 33312B944DD97846
10 changed files with 24 additions and 28 deletions

View File

@ -256,7 +256,7 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ]; environment.systemPackages = [ cfg.package (hiPrio cfg.cli) ];
systemd.services.bitcoind = { systemd.services.bitcoind = {
description = "Bitcoin daemon"; description = "Bitcoin daemon";
requires = [ "nix-bitcoin-secrets.target" ]; requires = [ "nix-bitcoin-secrets.target" ];

View File

@ -71,6 +71,7 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.nix-bitcoin.clightning (hiPrio cfg.cli) ];
users.users.clightning = { users.users.clightning = {
description = "clightning User"; description = "clightning User";
group = "clightning"; group = "clightning";

View File

@ -61,6 +61,8 @@ in {
}; };
config = mkIf cfg.enable (mkMerge [{ config = mkIf cfg.enable (mkMerge [{
environment.systemPackages = [ pkgs.nix-bitcoin.electrs ];
systemd.services.electrs = { systemd.services.electrs = {
description = "Electrs Electrum Server"; description = "Electrs Electrum Server";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];

View File

@ -32,11 +32,16 @@ in {
}; };
config = mkMerge [ config = mkMerge [
{ (mkIf (cfg.ledger || cfg.trezor) {
# Create group environment.systemPackages = with pkgs; [
nix-bitcoin.hwi
# Provides lsusb for debugging
usbutils
];
users.groups."${cfg.group}" = {}; users.groups."${cfg.group}" = {};
} })
(mkIf cfg.ledger { (mkIf cfg.ledger {
# Ledger Nano S according to https://github.com/LedgerHQ/udev-rules/blob/master/add_udev_rules.sh # Ledger Nano S according to https://github.com/LedgerHQ/udev-rules/blob/master/add_udev_rules.sh
# Don't use rules from nixpkgs because we want to use our own group. # Don't use rules from nixpkgs because we want to use our own group.
services.udev.packages = lib.singleton (pkgs.writeTextFile { services.udev.packages = lib.singleton (pkgs.writeTextFile {
@ -48,6 +53,7 @@ in {
}); });
}) })
(mkIf cfg.trezor { (mkIf cfg.trezor {
environment.systemPackages = [ pkgs.python3.pkgs.trezor ];
# Don't use rules from nixpkgs because we want to use our own group. # Don't use rules from nixpkgs because we want to use our own group.
services.udev.packages = lib.singleton (pkgs.writeTextFile { services.udev.packages = lib.singleton (pkgs.writeTextFile {
name = "trezord-udev-rules"; name = "trezord-udev-rules";

View File

@ -24,6 +24,7 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.nix-bitcoin.lightning-charge ];
systemd.services.lightning-charge = { systemd.services.lightning-charge = {
description = "Run lightning-charge"; description = "Run lightning-charge";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];

View File

@ -195,7 +195,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.nix-bitcoin.elementsd ]; environment.systemPackages = [
pkgs.nix-bitcoin.elementsd
(hiPrio cfg.cli)
(hiPrio cfg.swap-cli)
];
systemd.services.liquidd = { systemd.services.liquidd = {
description = "Elements daemon providing access to the Liquid sidechain"; description = "Elements daemon providing access to the Liquid sidechain";
requires = [ "bitcoind.service" ]; requires = [ "bitcoind.service" ];

View File

@ -77,7 +77,7 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ]; environment.systemPackages = [ cfg.package (hiPrio cfg.cli) ];
systemd.services.lnd = { systemd.services.lnd = {
description = "Run LND"; description = "Run LND";
path = [ pkgs.nix-bitcoin.bitcoind ]; path = [ pkgs.nix-bitcoin.bitcoind ];

View File

@ -52,6 +52,7 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.nix-bitcoin.nanopos ];
systemd.services.nanopos = { systemd.services.nanopos = {
description = "Run nanopos"; description = "Run nanopos";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
@ -60,7 +61,6 @@ in {
serviceConfig = { serviceConfig = {
EnvironmentFile = "${config.nix-bitcoin.secretsDir}/nanopos-env"; EnvironmentFile = "${config.nix-bitcoin.secretsDir}/nanopos-env";
ExecStart = "${pkgs.nix-bitcoin.nanopos}/bin/nanopos -y ${cfg.itemsFile} -p ${toString cfg.port} --show-bolt11"; ExecStart = "${pkgs.nix-bitcoin.nanopos}/bin/nanopos -y ${cfg.itemsFile} -p ${toString cfg.port} --show-bolt11";
User = "nanopos"; User = "nanopos";
Restart = "on-failure"; Restart = "on-failure";
RestartSec = "10s"; RestartSec = "10s";

View File

@ -108,30 +108,11 @@ in {
services.nix-bitcoin-webindex.enforceTor = true; services.nix-bitcoin-webindex.enforceTor = true;
environment.systemPackages = with pkgs; with nix-bitcoin; environment.systemPackages = with pkgs; [
[
tor tor
bitcoind
(hiPrio cfg.bitcoind.cli)
nodeinfo
jq jq
qrencode qrencode
] nix-bitcoin.nodeinfo
++ optionals cfg.clightning.enable [clightning (hiPrio cfg.clightning.cli)]
++ optionals cfg.lnd.enable [lnd (hiPrio cfg.lnd.cli)]
++ optionals cfg.lightning-charge.enable [lightning-charge]
++ optionals cfg.nanopos.enable [nanopos]
++ optionals cfg.nix-bitcoin-webindex.enable [nginx]
++ optionals cfg.liquidd.enable [elementsd (hiPrio cfg.liquidd.cli) (hiPrio cfg.liquidd.swap-cli)]
++ optionals cfg.spark-wallet.enable [spark-wallet]
++ optionals cfg.electrs.enable [electrs]
++ optionals (cfg.hardware-wallets.ledger || cfg.hardware-wallets.trezor) [
hwi
# To allow debugging issues with lsusb
usbutils
]
++ optionals cfg.hardware-wallets.trezor [
python3.pkgs.trezor
]; ];
# Create user operator which can use bitcoin-cli and lightning-cli # Create user operator which can use bitcoin-cli and lightning-cli

View File

@ -47,6 +47,7 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.nix-bitcoin.spark-wallet ];
services.tor.enable = cfg.onion-service; services.tor.enable = cfg.onion-service;
# requires client functionality for Bitcoin rate lookup # requires client functionality for Bitcoin rate lookup
services.tor.client.enable = true; services.tor.client.enable = true;