Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/clightning: init module #50531

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -493,6 +493,7 @@
./services/networking/btsync.nix
./services/networking/charybdis.nix
./services/networking/chrony.nix
./services/networking/clightning.nix
./services/networking/cjdns.nix
./services/networking/cntlm.nix
./services/networking/connman.nix
@@ -0,0 +1,108 @@
{ config, lib, pkgs, ... }:

with lib;

let
cfg = config.services.clightning;

mkLightningNode = cfg: network:
let
configFile = pkgs.writeText "clightning-${network}.conf" cfg.config;
in
{
description = "clightning ${network} node";

# clightning requires bitcoin-cli to talk to either spruned or bitcoind
path = [ pkgs.altcoins.bitcoind ];

after = [ "network.target" ];

This comment has been minimized.

Copy link
@erikarvstedt

erikarvstedt Nov 26, 2018

Member

There's no network.target for user units (see systemctl --user list-units -t target). You can remove this dependency.

wantedBy = optional cfg.autoStart "multi-user.target";

serviceConfig.ExecStart = "${pkgs.clightning}/bin/lightningd --lightning-dir=${cfg.dataDir} --conf=${configFile}";
serviceConfig.Restart = "on-abort";
};
in
{
options = {
services.clightning = {
networks = mkOption {

This comment has been minimized.

Copy link
@erikarvstedt

erikarvstedt Nov 26, 2018

Member

The name networks seems to be a leftover from openvpn. I think nodes would be more fitting.

default = {};

description = ''
Each attribute of this option defines a systemd user service that runs a
clightning node. The name of each systemd service is
<literal>clightning-<replaceable>network</replaceable>.service</literal>,
where <replaceable>network</replaceable> is the corresponding attribute
name.
'';

example = ''
{
mainnet = {
dataDir = "/home/user/.lightning-bitcoin";
config = '''
fee-per-satoshi=9000
lightning-dir=/home/user/.lightning-bitcoin
network=bitcoin
log-level=info
alias=mynode
rgb=ff0000
''';
};
testnet = {
dataDir = "/home/user/.lightning-testnet";
config = '''
fee-per-satoshi=1000
network=testnet
log-level=debug
alias=my-testnet-node
rgb=00ff00
''';
};
}
'';

This comment has been minimized.

Copy link
@erikarvstedt

erikarvstedt Nov 26, 2018

Member

I'd remove the whitespace here, one blank line should be enough.



type = types.attrsOf (types.submodule {
options = {

dataDir = mkOption {
type = types.path;

This comment has been minimized.

Copy link
@jb55

jb55 Nov 17, 2018

Author Contributor

forgot default here

description = ''
clightning data directory
'';
};

config = mkOption {
type = types.lines;
description = ''
Configuration of this clightning node.

This comment has been minimized.

Copy link
@Infinisil

Infinisil Nov 27, 2018

Member

Can you link to the docs for the configuration here?

'';
};

autoStart = mkOption {
default = true;
type = types.bool;
description = "Whether this clightning instance should be started automatically.";
};
};
});

This comment has been minimized.

Copy link
@erikarvstedt

erikarvstedt Nov 26, 2018

Member

Minor: These blank lines between brackets can be removed. There's more of them down below.

};

};

};

config = mkIf (cfg.networks != {}) {

systemd.user.services =
listToAttrs (mapAttrsFlatten (name: value: nameValuePair "clightning-${name}" (mkLightningNode value name)) cfg.networks);

This comment has been minimized.

Copy link
@erikarvstedt

erikarvstedt Nov 26, 2018

Member

Can be simplified to

mapAttrs' (name: value: nameValuePair "clightning-${name}" (mkLightningNode value name)) cfg.networks;


environment.systemPackages = [ pkgs.clightning ];

};

}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.