Skip to content

Commit

Permalink
faraday: v0.2.0 -> v0.2.3, refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sputn1ck committed Feb 1, 2021
1 parent f12cb27 commit 6688a71
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 18 deletions.
42 changes: 30 additions & 12 deletions modules/faraday.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,32 @@ let
cfg = config.services.faraday;
inherit (config) nix-bitcoin-services;
secretsDir = config.nix-bitcoin.secretsDir;
network = config.services.bitcoind.network;
rpclisten = "${cfg.rpcAddress}:${toString cfg.rpcPort}";
in {

options.services.faraday = {
enable = mkEnableOption "faraday";
package = mkOption {
type = types.package;
default = pkgs.nix-bitcoin.faraday;
default = config.nix-bitcoin.pkgs.faraday;
defaultText = "pkgs.nix-bitcoin.faraday";
description = "The package providing faraday binaries.";
};
rpclisten = mkOption {
type = types.str;
default = "localhost:8465";
description = "Address to listen on for gRPC clients.";
rpcAddress = mkOption {
type = types.str;
default = "localhost";
description = "Address to listen for gRPC connections.";
};
rpcPort = mkOption {
type = types.port;
default = 8465;
description = "Port to listen for gRPC connections.";
};
faradayDir = mkOption {
type = types.path;
default = "/var/lib/faraday";
description = "The data directory for faraday.";
};
extraArgs = mkOption {
type = types.separatedString " ";
Expand All @@ -30,7 +42,9 @@ in {
default = pkgs.writeScriptBin "frcli"
# Switch user because lnd makes datadir contents readable by user only
''
exec sudo -u lnd ${cfg.package}/bin/frcli --rpcserver ${cfg.rpclisten} "$@"
${cfg.package}/bin/frcli \
--rpcserver ${rpclisten} \
--faradaydir ${cfg.faradayDir} "$@"
'';
description = "Binary to connect with the lnd instance.";
};
Expand All @@ -52,18 +66,22 @@ in {
requires = [ "lnd.service" ];
after = [ "lnd.service" ];
serviceConfig = nix-bitcoin-services.defaultHardening // {
preStart = ''
mkdir -p ${cfg.baseDir}
chown -R 'lnd:lnd' '${cfg.baseDir}'
'';
ExecStart = ''
${cfg.package}/bin/faraday \
--rpclisten=${cfg.rpclisten} \
--rpcserver=${config.services.lnd.listen}:10009 \
--macaroondir=${config.services.lnd.dataDir}/chain/bitcoin/mainnet \
--tlscertpath=${secretsDir}/lnd-cert \
${cfg.extraArgs}
--faradaydir=${cfg.faradayDir} \
--rpclisten=${rpclisten} \
--lnd.rpcserver=${config.services.lnd.rpcAddress}:${toString config.services.lnd.rpcPort} \
--lnd.macaroondir=${config.services.lnd.networkDir} \
--lnd.tlscertpath=${secretsDir}/lnd-cert
'';
User = "lnd";
Restart = "on-failure";
RestartSec = "10s";
ReadWritePaths = "${config.services.lnd.dataDir}";
ReadWritePaths = "${cfg.faradayDir}";
} // (if cfg.enforceTor
then nix-bitcoin-services.allowTor
else nix-bitcoin-services.allowAnyIP);
Expand Down
4 changes: 4 additions & 0 deletions modules/netns-isolation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ in {
id = 27;
connections = [ "lnd" ];
};
faraday = {
id = 28;
connections = [ "lnd" ];
};
};

services.bitcoind = {
Expand Down
2 changes: 1 addition & 1 deletion pkgs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ let self = {
netns-exec = pkgs.callPackage ./netns-exec { };
lightning-loop = pkgs.callPackage ./lightning-loop { };
lightning-pool = pkgs.callPackage ./lightning-pool { };
faraday = pkgs.callPackage ./faraday { };
extra-container = pkgs.callPackage ./extra-container { };
clightning-plugins = import ./clightning-plugins pkgs self.nbPython3Packages;
clboss = pkgs.callPackage ./clboss { };

nbPython3Packages = (pkgs.python3.override {
packageOverrides = pySelf: super: import ./python-packages self pySelf;
}).pkgs;
faraday = pkgs.callPackage ./faraday { };

pinned = import ./pinned.nix;

Expand Down
6 changes: 3 additions & 3 deletions pkgs/faraday/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

buildGoModule rec {
pname = "faraday";
version = "0.2.0-alpha";
version = "0.2.3-alpha";

src = fetchurl {
url = "https://github.com/lightninglabs/faraday/archive/v${version}.tar.gz";
# Use ./get-sha256.sh to fetch latest (verified) sha256
sha256 = "58cdb977909e2188837ee0d00ec47a520baeb3bb09719ea6e1fe23efb9283d06";
sha256 = "c016e2b16160f24abdfce0f71cdb848da3e3d78cff450fb353017d4104bd616e";
};

subPackages = [ "cmd/faraday" "cmd/frcli" ];

vendorSha256 = "1vmspdlh018p453rbif5yc2fqjipnz012rlbilwcrkjric24qbsk";
vendorSha256 = "1hh99nfprlmhkc36arg3w1kxby59i2l7n258cp40niv7bjn37hrq";

meta = with lib; {
description = " Faraday: Lightning Channel Management & Optimization Tool";
Expand Down
5 changes: 3 additions & 2 deletions pkgs/faraday/get-sha256.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# /bin/bash

#! /usr/bin/env nix-shell
#! nix-shell -i bash -p git gnupg
set -euo pipefail

TMPDIR="$(mktemp -d -p /tmp)"
trap "rm -rf $TMPDIR" EXIT
Expand Down

0 comments on commit 6688a71

Please sign in to comment.