2018-12-01 08:36:07 -08:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
2019-04-27 16:53:26 -07:00
|
|
|
nix-bitcoin-services = pkgs.callPackage ./nix-bitcoin-services.nix { };
|
2018-12-01 08:36:07 -08:00
|
|
|
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 {
|
2019-01-02 07:17:57 -08:00
|
|
|
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";
|
2019-03-25 06:27:21 -07:00
|
|
|
ExecStart = "${pkgs.lightning-charge}/bin/charged -l ${config.services.clightning.dataDir} -d ${config.services.clightning.dataDir}/lightning-charge.db";
|
2019-01-02 07:17:57 -08:00
|
|
|
# Unfortunately c-lightning doesn't allow setting the permissions of the rpc socket,
|
|
|
|
# so this must run as the clightning user
|
|
|
|
# https://github.com/ElementsProject/lightning/issues/1366
|
|
|
|
User = "clightning";
|
|
|
|
Restart = "on-failure";
|
|
|
|
RestartSec = "10s";
|
2019-04-27 16:53:26 -07:00
|
|
|
} // nix-bitcoin-services.defaultHardening
|
2019-05-03 03:44:16 -07:00
|
|
|
// nix-bitcoin-services.nodejs
|
2019-04-27 16:53:26 -07:00
|
|
|
// nix-bitcoin-services.allowTor;
|
2018-12-01 08:36:07 -08:00
|
|
|
};
|
2019-01-02 07:17:57 -08:00
|
|
|
};
|
2018-12-01 08:36:07 -08:00
|
|
|
}
|