Add lightning charge module
This commit is contained in:
parent
c61c21e2e1
commit
21f9462651
@ -9,8 +9,11 @@ fi
|
|||||||
|
|
||||||
echo Installing apg through nix-env
|
echo Installing apg through nix-env
|
||||||
nix-env -i apg
|
nix-env -i apg
|
||||||
echo Creating bitcoin RPC password
|
echo Write secrets to $SECRETSFILE
|
||||||
echo \{ >> $SECRETSFILE
|
{
|
||||||
echo " bitcoinrpcpassword = \"$(apg -m 20 -x 20 -M Ncl -n 1)\";" >> $SECRETSFILE
|
echo \{
|
||||||
echo \} >> $SECRETSFILE
|
echo " bitcoinrpcpassword = \"$(apg -m 20 -x 20 -M Ncl -n 1)\";"
|
||||||
|
echo " lightning-charge-api-token = \"$(apg -m 20 -x 20 -M Ncl -n 1)\";"
|
||||||
|
echo \}
|
||||||
|
} >> $SECRETSFILE
|
||||||
echo Done
|
echo Done
|
||||||
|
56
modules/lightning-charge.nix
Normal file
56
modules/lightning-charge.nix
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.services.lightning-charge;
|
||||||
|
in {
|
||||||
|
options.services.lightning-charge = {
|
||||||
|
enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
If enabled, the lightning-charge service will be installed.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
clightning-datadir = mkOption {
|
||||||
|
type = types.string;
|
||||||
|
default = "/var/lib/clighting/";
|
||||||
|
description = ''
|
||||||
|
Data directory of the clightning service
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
users.users.lightning-charge =
|
||||||
|
{
|
||||||
|
description = "lightning-charge User";
|
||||||
|
group = "lightning-charge";
|
||||||
|
extraGroups = [ "keys" ];
|
||||||
|
};
|
||||||
|
users.groups.lightning-charge = {
|
||||||
|
name = "lightning-charge";
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services.lightning-charge =
|
||||||
|
{ description = "Run lightning-charge";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
requires = [ "clightning.service" ];
|
||||||
|
after = [ "clightning.service" ];
|
||||||
|
serviceConfig =
|
||||||
|
{
|
||||||
|
EnvironmentFile = "/secrets/lightning-charge-api-token";
|
||||||
|
ExecStart = "${pkgs.lightning-charge.package}/bin/charged -l ${config.services.clightning.dataDir} -d ${config.services.clightning.dataDir}/lightning-charge.db";
|
||||||
|
|
||||||
|
User = "clightning";
|
||||||
|
Restart = "on-failure";
|
||||||
|
RestartSec = "10s";
|
||||||
|
PrivateTmp = "true";
|
||||||
|
ProtectSystem = "full";
|
||||||
|
NoNewPrivileges = "true";
|
||||||
|
PrivateDevices = "true";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
@ -7,9 +7,10 @@ let
|
|||||||
in {
|
in {
|
||||||
imports =
|
imports =
|
||||||
[
|
[
|
||||||
./bitcoind.nix
|
|
||||||
./tor.nix
|
./tor.nix
|
||||||
|
./bitcoind.nix
|
||||||
./clightning.nix
|
./clightning.nix
|
||||||
|
./lightning-charge.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
options.services.nixbitcoin = {
|
options.services.nixbitcoin = {
|
||||||
@ -53,6 +54,8 @@ in {
|
|||||||
services.clightning.enable = true;
|
services.clightning.enable = true;
|
||||||
services.clightning.bitcoin-rpcuser = config.services.bitcoind.rpcuser;
|
services.clightning.bitcoin-rpcuser = config.services.bitcoind.rpcuser;
|
||||||
|
|
||||||
|
services.lightning-charge.enable = true;
|
||||||
|
|
||||||
# nodeinfo
|
# nodeinfo
|
||||||
systemd.services.nodeinfo = {
|
systemd.services.nodeinfo = {
|
||||||
description = "Get node info";
|
description = "Get node info";
|
||||||
|
@ -14,5 +14,11 @@ in
|
|||||||
deployment.keys.bitcoin-rpcpassword.user = "bitcoin";
|
deployment.keys.bitcoin-rpcpassword.user = "bitcoin";
|
||||||
deployment.keys.bitcoin-rpcpassword.group = "bitcoinrpc";
|
deployment.keys.bitcoin-rpcpassword.group = "bitcoinrpc";
|
||||||
deployment.keys.bitcoin-rpcpassword.permissions = "0440";
|
deployment.keys.bitcoin-rpcpassword.permissions = "0440";
|
||||||
|
|
||||||
|
deployment.keys.lightning-charge-api-token.text = "API_TOKEN=" + secrets.lightning-charge-api-token;
|
||||||
|
deployment.keys.lightning-charge-api-token.destDir = "/secrets/";
|
||||||
|
deployment.keys.lightning-charge-api-token.user = "clightning";
|
||||||
|
deployment.keys.lightning-charge-api-token.group = "clightning";
|
||||||
|
deployment.keys.lightning-charge-api-token.permissions = "0440";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user