lightning-charge: add netns
- Adds lightning-charge to netns-isolation.services - Adds cfg.enforceTor to bring lightning-charge in line with other services - Adds extraArgs option to allow using lightning-charge with network namespaces - Adds host option (defaults to localhost) as target of hidden service
This commit is contained in:
parent
c4ab73d51f
commit
7369f0a7ec
@ -21,6 +21,17 @@ in {
|
|||||||
default = "/var/lib/lightning-charge";
|
default = "/var/lib/lightning-charge";
|
||||||
description = "The data directory for lightning-charge.";
|
description = "The data directory for lightning-charge.";
|
||||||
};
|
};
|
||||||
|
host = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "127.0.0.1";
|
||||||
|
description = "http server listen address";
|
||||||
|
};
|
||||||
|
extraArgs = mkOption {
|
||||||
|
type = types.separatedString " ";
|
||||||
|
default = "";
|
||||||
|
description = "Extra command line arguments passed to lightning-charge.";
|
||||||
|
};
|
||||||
|
enforceTor = nix-bitcoin-services.enforceTor;
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
@ -60,13 +71,15 @@ in {
|
|||||||
# Needed to access clightning.dataDir in preStart
|
# Needed to access clightning.dataDir in preStart
|
||||||
PermissionsStartOnly = "true";
|
PermissionsStartOnly = "true";
|
||||||
EnvironmentFile = "${config.nix-bitcoin.secretsDir}/lightning-charge-env";
|
EnvironmentFile = "${config.nix-bitcoin.secretsDir}/lightning-charge-env";
|
||||||
ExecStart = "${pkgs.nix-bitcoin.lightning-charge}/bin/charged -l ${config.services.clightning.dataDir}/bitcoin -d ${cfg.dataDir}/lightning-charge.db";
|
ExecStart = "${pkgs.nix-bitcoin.lightning-charge}/bin/charged -l ${config.services.clightning.dataDir}/bitcoin -d ${cfg.dataDir}/lightning-charge.db -i ${cfg.host} ${cfg.extraArgs}";
|
||||||
User = user;
|
User = user;
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
RestartSec = "10s";
|
RestartSec = "10s";
|
||||||
ReadWritePaths = "${cfg.dataDir}";
|
ReadWritePaths = "${cfg.dataDir}";
|
||||||
} // nix-bitcoin-services.nodejs
|
} // (if cfg.enforceTor
|
||||||
// nix-bitcoin-services.allowTor;
|
then nix-bitcoin-services.allowTor
|
||||||
|
else nix-bitcoin-services.allowAnyIP)
|
||||||
|
// nix-bitcoin-services.nodejs;
|
||||||
};
|
};
|
||||||
nix-bitcoin.secrets.lightning-charge-env.user = user;
|
nix-bitcoin.secrets.lightning-charge-env.user = user;
|
||||||
};
|
};
|
||||||
|
@ -110,6 +110,11 @@ in {
|
|||||||
# communicates with clightning over lightning-rpc socket
|
# communicates with clightning over lightning-rpc socket
|
||||||
connections = [];
|
connections = [];
|
||||||
};
|
};
|
||||||
|
lightning-charge = {
|
||||||
|
id = 18;
|
||||||
|
# communicates with clightning over lightning-rpc socket
|
||||||
|
connections = [];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services = {
|
systemd.services = {
|
||||||
@ -263,6 +268,9 @@ in {
|
|||||||
extraArgs = "--no-tls";
|
extraArgs = "--no-tls";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# lightning-charge: Custom netns configs
|
||||||
|
services.lightning-charge.host = mkIf config.services.lightning-charge.enable netns.lightning-charge.address;
|
||||||
|
|
||||||
})
|
})
|
||||||
# Custom netns config option values if netns-isolation not enabled
|
# Custom netns config option values if netns-isolation not enabled
|
||||||
(mkIf (!cfg.enable) {
|
(mkIf (!cfg.enable) {
|
||||||
|
@ -127,6 +127,8 @@ in {
|
|||||||
enforceTor = true;
|
enforceTor = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
services.lightning-charge.enforceTor = true;
|
||||||
|
|
||||||
services.nix-bitcoin-webindex.enforceTor = true;
|
services.nix-bitcoin-webindex.enforceTor = true;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user