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:
Erik Arvstedt 2019-11-27 14:04:33 +01:00
parent b90bf6691b
commit 1833b15888
No known key found for this signature in database
GPG key ID: 33312B944DD97846
5 changed files with 19 additions and 7 deletions

View file

@ -57,6 +57,16 @@ in {
default = "/var/lib/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;
};