Add spark-wallet
This commit is contained in:
parent
c3cd4657fb
commit
25d52c4d10
|
@ -20,6 +20,9 @@ Profiles
|
|||
* [lightning charge](https://github.com/ElementsProject/lightning-charge)
|
||||
* [nanopos](https://github.com/ElementsProject/nanopos)
|
||||
* adds an index page using nginx to display node information and link to nanopos
|
||||
* [spark-wallet](https://github.com/shesek/spark-wallet)
|
||||
* Notes: run `nodeinfo` to get its onion address and `systemctl status spark-wallet` to get the access key.
|
||||
When entering the onion address on the Android app don't forgot to prepend "http://"
|
||||
|
||||
The data directories can be found in `/var/lib`.
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ let
|
|||
nodeinfo = (import pkgs/nodeinfo.nix);
|
||||
lightning-charge = import pkgs/lightning-charge.nix { inherit pkgs; };
|
||||
nanopos = import pkgs/nanopos.nix { inherit pkgs; };
|
||||
spark-wallet = import pkgs/spark-wallet.nix { inherit pkgs; };
|
||||
liquidd = import pkgs/liquidd.nix;
|
||||
in {
|
||||
imports =
|
||||
|
@ -20,6 +21,7 @@ in {
|
|||
inherit nodeinfo;
|
||||
inherit lightning-charge;
|
||||
inherit nanopos;
|
||||
inherit spark-wallet;
|
||||
liquidd = (pkgs.callPackage liquidd { });
|
||||
};
|
||||
services.nixbitcoin.enable = true;
|
||||
|
|
|
@ -15,6 +15,7 @@ echo Write secrets to $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 " liquidrpcpassword = \"$(apg -m 20 -x 20 -M Ncl -n 1)\";"
|
||||
echo " spark-wallet-password = \"$(apg -m 20 -x 20 -M Ncl -n 1)\";"
|
||||
echo \}
|
||||
} >> $SECRETSFILE
|
||||
echo Done
|
||||
|
|
|
@ -15,6 +15,7 @@ let
|
|||
liquidd
|
||||
lightning-charge.package
|
||||
nanopos.package
|
||||
spark-wallet.package
|
||||
nodejs-8_x
|
||||
nginx
|
||||
];
|
||||
|
@ -27,6 +28,7 @@ in {
|
|||
./nanopos.nix
|
||||
./nixbitcoin-webindex.nix
|
||||
./liquid.nix
|
||||
./spark-wallet.nix
|
||||
];
|
||||
|
||||
options.services.nixbitcoin = {
|
||||
|
@ -125,6 +127,13 @@ in {
|
|||
services.nanopos.enable = cfg.modules == "all";
|
||||
services.nixbitcoin-webindex.enable = cfg.modules == "all";
|
||||
services.clightning.autolisten = cfg.modules == "all";
|
||||
services.spark-wallet.enable = cfg.modules == "all";
|
||||
services.tor.hiddenServices.spark-wallet = {
|
||||
map = [{
|
||||
port = 80; toPort = 9737;
|
||||
}];
|
||||
version = 3;
|
||||
};
|
||||
environment.systemPackages = if (cfg.modules == "all") then (minimalPackages ++ allPackages) else minimalPackages;
|
||||
};
|
||||
}
|
||||
|
|
44
modules/spark-wallet.nix
Normal file
44
modules/spark-wallet.nix
Normal file
|
@ -0,0 +1,44 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.spark-wallet;
|
||||
in {
|
||||
options.services.spark-wallet = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
If enabled, the spark-wallet service will be installed.
|
||||
'';
|
||||
};
|
||||
ln-path = mkOption {
|
||||
type = types.path;
|
||||
default = "/var/lib/clightning";
|
||||
description = ''
|
||||
"The path of the clightning data directory.";
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
systemd.services.spark-wallet =
|
||||
{ description = "Run spark-wallet";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
requires = [ "clightning.service" ];
|
||||
after = [ "clightning.service" ];
|
||||
serviceConfig =
|
||||
{
|
||||
ExecStart = "${pkgs.spark-wallet.package}/bin/spark-wallet --ln-path ${cfg.ln-path} -k -c /secrets/spark-wallet-password";
|
||||
User = "clightning";
|
||||
Restart = "on-failure";
|
||||
RestartSec = "10s";
|
||||
PrivateTmp = "true";
|
||||
ProtectSystem = "full";
|
||||
NoNewPrivileges = "true";
|
||||
PrivateDevices = "true";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
10
network.nix
10
network.nix
|
@ -29,6 +29,13 @@ let
|
|||
group = "liquid";
|
||||
permissions = "0440";
|
||||
};
|
||||
spark-wallet-login = {
|
||||
text = "login=" + "spark-wallet:" + secrets.spark-wallet-password;
|
||||
destDir = "/secrets/";
|
||||
user = "clightning";
|
||||
group = "clightning";
|
||||
permissions = "0440";
|
||||
};
|
||||
in {
|
||||
network.description = "Bitcoin Core node";
|
||||
|
||||
|
@ -41,6 +48,7 @@ in {
|
|||
inherit bitcoin-rpcpassword lightning-charge-api-token;
|
||||
}
|
||||
// (if (config.services.nanopos.enable) then { inherit lightning-charge-api-token-for-nanopos; } else { })
|
||||
// (if (config.services.liquidd.enable) then { inherit liquid-rpcpassword; } else { });
|
||||
// (if (config.services.liquidd.enable) then { inherit liquid-rpcpassword; } else { })
|
||||
// (if (config.services.spark-wallet.enable) then { inherit spark-wallet-login; } else { });
|
||||
} // (bitcoin-node { inherit config pkgs; });
|
||||
}
|
||||
|
|
|
@ -16,3 +16,15 @@ if [ -e "$NGINX_ONION_FILE" ]; then
|
|||
NGINX_ONION="$(cat $NGINX_ONION_FILE)"
|
||||
echo NGINX_ONION="$NGINX_ONION"
|
||||
fi
|
||||
|
||||
NGINX_ONION_FILE=/var/lib/tor/onion/nginx/hostname
|
||||
if [ -e "$NGINX_ONION_FILE" ]; then
|
||||
NGINX_ONION="$(cat $NGINX_ONION_FILE)"
|
||||
echo NGINX_ONION="$NGINX_ONION"
|
||||
fi
|
||||
|
||||
SPARKWALLET_ONION_FILE=/var/lib/tor/onion/spark-wallet/hostname
|
||||
if [ -e "$SPARKWALLET_ONION_FILE" ]; then
|
||||
SPARKWALLET_ONION="$(cat $SPARKWALLET_ONION_FILE)"
|
||||
echo SPARKWALLET_ONION="http://$SPARKWALLET_ONION"
|
||||
fi
|
||||
|
|
33
pkgs/spark-wallet.nix
Normal file
33
pkgs/spark-wallet.nix
Normal file
|
@ -0,0 +1,33 @@
|
|||
{pkgs ? import <nixpkgs> {
|
||||
inherit system;
|
||||
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-8_x"}:
|
||||
|
||||
|
||||
with pkgs;
|
||||
let
|
||||
d1 = stdenv.mkDerivation {
|
||||
name = "spark-wallet-sources";
|
||||
src = fetchurl {
|
||||
url = "https://registry.npmjs.org/spark-wallet/-/spark-wallet-0.2.0-rc.3.tgz";
|
||||
sha256 = "991855f6c103c3e2abfd6421597db31948bc3fb967d9066f0d804a88c22390fd";
|
||||
};
|
||||
|
||||
buildInputs = [ nodePackages.node2nix git ];
|
||||
|
||||
unpackPhase = ''
|
||||
mkdir -p $out
|
||||
tar -xzf $src -C $out
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cd $out/package
|
||||
${nodePackages.node2nix}/bin/node2nix -8 package.json
|
||||
'';
|
||||
};
|
||||
# import from derivation (IFD)
|
||||
packages = import (d1 + "/package/default.nix") {
|
||||
inherit pkgs system;
|
||||
};
|
||||
in
|
||||
packages
|
Loading…
Reference in New Issue
Block a user