mirror of
https://github.com/fort-nix/nix-bitcoin.git
synced 2024-11-30 03:32:05 +03:00
clightning: add cli option
An executable is more robust to use than shell aliases. This is also a preparation for commit 'add module test' because the NixOS testing framework makes interactive aliases hard to use: It unsets 'PS1' which is used by programs/bash/bash.nix to detect interactive shells.
This commit is contained in:
parent
b90bf6691b
commit
1833b15888
@ -57,6 +57,16 @@ in {
|
|||||||
default = "/var/lib/clightning";
|
default = "/var/lib/clightning";
|
||||||
description = "The data directory for clightning.";
|
description = "The data directory for clightning.";
|
||||||
};
|
};
|
||||||
|
cli = mkOption {
|
||||||
|
readOnly = true;
|
||||||
|
default = pkgs.writeScriptBin "lightning-cli"
|
||||||
|
# Switch user because c-lightning doesn't allow setting the permissions of the rpc socket
|
||||||
|
# https://github.com/ElementsProject/lightning/issues/1366
|
||||||
|
''
|
||||||
|
exec sudo -u clightning ${pkgs.nix-bitcoin.clightning}/bin/lightning-cli --lightning-dir='${cfg.dataDir}' "$@"
|
||||||
|
'';
|
||||||
|
description = "Binary to connect with the clightning instance.";
|
||||||
|
};
|
||||||
enforceTor = nix-bitcoin-services.enforceTor;
|
enforceTor = nix-bitcoin-services.enforceTor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,7 +74,12 @@ in {
|
|||||||
description = "Get node info";
|
description = "Get node info";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
after = [ "nodeinfo.service" ];
|
after = [ "nodeinfo.service" ];
|
||||||
path = with pkgs; [ nix-bitcoin.nodeinfo nix-bitcoin.clightning jq sudo ];
|
path = with pkgs; [
|
||||||
|
nix-bitcoin.nodeinfo
|
||||||
|
config.services.clightning.cli
|
||||||
|
jq
|
||||||
|
sudo
|
||||||
|
];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart="${pkgs.bash}/bin/bash ${createWebIndex}";
|
ExecStart="${pkgs.bash}/bin/bash ${createWebIndex}";
|
||||||
User = "root";
|
User = "root";
|
||||||
|
@ -102,9 +102,6 @@ in {
|
|||||||
services.onion-chef.access.operator = [ "bitcoind" "clightning" "nginx" "liquidd" "spark-wallet" "electrs" "sshd" ];
|
services.onion-chef.access.operator = [ "bitcoind" "clightning" "nginx" "liquidd" "spark-wallet" "electrs" "sshd" ];
|
||||||
|
|
||||||
environment.interactiveShellInit = ''
|
environment.interactiveShellInit = ''
|
||||||
${optionalString (config.services.clightning.enable) ''
|
|
||||||
alias lightning-cli='sudo -u clightning lightning-cli --lightning-dir=${config.services.clightning.dataDir}'
|
|
||||||
''}
|
|
||||||
${optionalString (config.services.lnd.enable) ''
|
${optionalString (config.services.lnd.enable) ''
|
||||||
alias lncli='sudo -u lnd lncli --tlscertpath /secrets/lnd_cert --macaroonpath ${config.services.lnd.dataDir}/chain/bitcoin/mainnet/admin.macaroon'
|
alias lncli='sudo -u lnd lncli --tlscertpath /secrets/lnd_cert --macaroonpath ${config.services.lnd.dataDir}/chain/bitcoin/mainnet/admin.macaroon'
|
||||||
''}
|
''}
|
||||||
@ -175,7 +172,7 @@ in {
|
|||||||
jq
|
jq
|
||||||
qrencode
|
qrencode
|
||||||
]
|
]
|
||||||
++ optionals config.services.clightning.enable [clightning]
|
++ optionals config.services.clightning.enable [clightning (hiPrio config.services.clightning.cli)]
|
||||||
++ optionals config.services.lnd.enable [lnd]
|
++ optionals config.services.lnd.enable [lnd]
|
||||||
++ optionals config.services.lightning-charge.enable [lightning-charge]
|
++ optionals config.services.lightning-charge.enable [lightning-charge]
|
||||||
++ optionals config.services.nanopos.enable [nanopos]
|
++ optionals config.services.nanopos.enable [nanopos]
|
||||||
|
@ -6,7 +6,7 @@ let
|
|||||||
cfg = config.services.recurring-donations;
|
cfg = config.services.recurring-donations;
|
||||||
inherit (config) nix-bitcoin-services;
|
inherit (config) nix-bitcoin-services;
|
||||||
recurring-donations-script = pkgs.writeScript "recurring-donations.sh" ''
|
recurring-donations-script = pkgs.writeScript "recurring-donations.sh" ''
|
||||||
LNCLI="lightning-cli --lightning-dir=${config.services.clightning.dataDir}"
|
LNCLI="${pkgs.nix-bitcoin.clightning}/bin/lightning-cli --lightning-dir=${config.services.clightning.dataDir}"
|
||||||
pay_tallycoin() {
|
pay_tallycoin() {
|
||||||
NAME=$1
|
NAME=$1
|
||||||
AMOUNT=$2
|
AMOUNT=$2
|
||||||
|
@ -5,7 +5,7 @@ BITCOIND_ONION="$(cat /var/lib/onion-chef/operator/bitcoind)"
|
|||||||
echo BITCOIND_ONION="$BITCOIND_ONION"
|
echo BITCOIND_ONION="$BITCOIND_ONION"
|
||||||
|
|
||||||
if [ -x "$(command -v lightning-cli)" ]; then
|
if [ -x "$(command -v lightning-cli)" ]; then
|
||||||
CLIGHTNING_NODEID=$(sudo -u clightning lightning-cli --lightning-dir=/var/lib/clightning getinfo | jq -r '.id')
|
CLIGHTNING_NODEID=$(lightning-cli getinfo | jq -r '.id')
|
||||||
CLIGHTNING_ONION="$(cat /var/lib/onion-chef/operator/clightning)"
|
CLIGHTNING_ONION="$(cat /var/lib/onion-chef/operator/clightning)"
|
||||||
CLIGHTNING_ID="$CLIGHTNING_NODEID@$CLIGHTNING_ONION:9735"
|
CLIGHTNING_ID="$CLIGHTNING_NODEID@$CLIGHTNING_ONION:9735"
|
||||||
echo CLIGHTNING_NODEID="$CLIGHTNING_NODEID"
|
echo CLIGHTNING_NODEID="$CLIGHTNING_NODEID"
|
||||||
|
Loading…
Reference in New Issue
Block a user