clightning: add package option

This commit is contained in:
Erik Arvstedt 2022-05-22 15:56:15 +02:00
parent 041162d1e3
commit ae94665ad1
No known key found for this signature in database
GPG Key ID: 33312B944DD97846

View File

@ -64,10 +64,16 @@ let
default = cfg.user; default = cfg.user;
description = "The group as which to run clightning."; description = "The group as which to run clightning.";
}; };
package = mkOption {
type = types.package;
default = nbPkgs.clightning;
defaultText = "config.nix-bitcoin.pkgs.clightning";
description = "The package providing clightning binaries.";
};
cli = mkOption { cli = mkOption {
readOnly = true; readOnly = true;
default = pkgs.writeScriptBin "lightning-cli" '' default = pkgs.writeScriptBin "lightning-cli" ''
${nbPkgs.clightning}/bin/lightning-cli --lightning-dir='${cfg.dataDir}' "$@" ${cfg.package}/bin/lightning-cli --lightning-dir='${cfg.dataDir}' "$@"
''; '';
defaultText = "(See source)"; defaultText = "(See source)";
description = "Binary to connect with the clightning instance."; description = "Binary to connect with the clightning instance.";
@ -120,7 +126,7 @@ in {
rpc.threads = 16; rpc.threads = 16;
}; };
environment.systemPackages = [ nbPkgs.clightning (hiPrio cfg.cli) ]; environment.systemPackages = [ cfg.package (hiPrio cfg.cli) ];
systemd.tmpfiles.rules = [ systemd.tmpfiles.rules = [
"d '${cfg.dataDir}' 0770 ${cfg.user} ${cfg.group} - -" "d '${cfg.dataDir}' 0770 ${cfg.user} ${cfg.group} - -"
@ -144,7 +150,7 @@ in {
} > '${cfg.dataDir}/config' } > '${cfg.dataDir}/config'
''; '';
serviceConfig = nbLib.defaultHardening // { serviceConfig = nbLib.defaultHardening // {
ExecStart = "${nbPkgs.clightning}/bin/lightningd --lightning-dir=${cfg.dataDir}"; ExecStart = "${cfg.package}/bin/lightningd --lightning-dir=${cfg.dataDir}";
User = cfg.user; User = cfg.user;
Restart = "on-failure"; Restart = "on-failure";
RestartSec = "10s"; RestartSec = "10s";