Merge branch 'nixbitcoin-user-config'

This commit is contained in:
Jonas Nick 2019-04-12 09:04:13 +00:00
commit c04fefbec5
No known key found for this signature in database
GPG Key ID: 4861DBF262123605
2 changed files with 63 additions and 42 deletions

View File

@ -2,18 +2,59 @@
# your system. Help is available in the configuration.nix(5) man page # your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help). # and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, ... }: { config, pkgs, ... }: { imports = [ ./modules/nix-bitcoin.nix
{
imports = [
./modules/nix-bitcoin.nix
# FIXME: Uncomment next line to import your hardware configuration. If so, # FIXME: Uncomment next line to import your hardware configuration. If so,
# add the hardware configuration file to the same directory as this file. # add the hardware configuration file to the same directory as this file.
# This is not needed when deploying to a virtual box. # This is not needed when deploying to a virtual box.
#./hardware-configuration.nix #./hardware-configuration.nix
]; ];
# FIXME: Enable modules by uncommenting their respective line. Disable
# modules by commenting out their respective line. Enable this module to
# use the nix-bitcoin node configuration. Only disable this if you know what
# you are doing.
services.nix-bitcoin.enable = true; services.nix-bitcoin.enable = true;
# FIXME Install and use minimal or all modules
services.nix-bitcoin.modules = "all"; ### CLIGHTNING
# Enable this module to use clightning, a Lightning Network implementation
# in C.
services.clightning.enable = true;
# Enable this option to listen for incoming lightning connections. By
# default nix-bitcoin nodes offer outgoing connectivity.
# services.clightning.autolisten = true;
### SPARK WALLET
# Enable this module to use spark-wallet, a minimalistic wallet GUI for
# c-lightning, accessible over the web or through mobile and desktop apps.
# Only enable this if clightning is enabled.
# services.spark-wallet.enable = true;
### ELECTRS
# Enable this module to use electrs, an efficient re-implementation of
# Electrum Server in Rust.
# services.electrs.enable = true;
### LIQUIDD
# Enable this module to use liquidd, a daemon for an inter-exchange
# settlement network linking together cryptocurrency exchanges and
# institutions around the world.
# services.liquidd.enable = true;
### LIGHTNING CHARGE
# Enable this module to use lightning-charge, a simple drop-in solution for
# accepting lightning payments. Only enable this if clightning is enabled.
# services.lightning-charge.enable = true;
### NANOPOS
# Enable this module to use nanopos, a simple Lightning point-of-sale
# system, powered by Lightning Charge. Only enable this if clightning and
# lightning-charge are enabled.
# services.nanopos.enable = true;
### WEBINDEX
# Enable this module to use the nix-bitcoin-webindex, a simple website
# displaying your node information and link to nanopos store. Only enable
# this if clightning, lightning-charge, and nanopos are enabled.
# services.nix-bitcoin-webindex.enable = true;
# FIXME: Define your hostname. # FIXME: Define your hostname.
networking.hostName = "nix-bitcoin"; networking.hostName = "nix-bitcoin";

View File

@ -4,23 +4,7 @@ with lib;
let let
cfg = config.services.nix-bitcoin; cfg = config.services.nix-bitcoin;
minimalPackages = with pkgs; [ operatorCopySSH = pkgs.writeText "operator-copy-ssh.sh" ''
tor
bitcoin
clightning
nodeinfo
banlist
jq
];
allPackages = with pkgs; [
liquidd
lightning-charge
nanopos
spark-wallet
nodejs-8_x
nginx
];
operatorCopySSH = pkgs.writeText "operator-copy-ssh.sh" ''
mkdir -p ${config.users.users.operator.home}/.ssh mkdir -p ${config.users.users.operator.home}/.ssh
if [ -e "${config.users.users.root.home}/.vbox-nixops-client-key" ]; then if [ -e "${config.users.users.root.home}/.vbox-nixops-client-key" ]; then
cp ${config.users.users.root.home}/.vbox-nixops-client-key ${config.users.users.operator.home}/.ssh/authorized_keys cp ${config.users.users.root.home}/.vbox-nixops-client-key ${config.users.users.operator.home}/.ssh/authorized_keys
@ -52,13 +36,6 @@ in {
If enabled, the nix-bitcoin service will be installed. If enabled, the nix-bitcoin service will be installed.
''; '';
}; };
modules = mkOption {
type = types.enum [ "minimal" "all" ];
default = "minimal";
description = ''
If enabled, the nix-bitcoin service will be installed.
'';
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
@ -102,10 +79,7 @@ in {
users.groups.bitcoinrpc = {}; users.groups.bitcoinrpc = {};
# clightning # clightning
services.clightning = { services.clightning.bitcoin-rpcuser = config.services.bitcoind.rpcuser;
enable = true;
bitcoin-rpcuser = config.services.bitcoind.rpcuser;
};
services.clightning.proxy = config.services.tor.client.socksListenAddress; services.clightning.proxy = config.services.tor.client.socksListenAddress;
services.clightning.always-use-proxy = true; services.clightning.always-use-proxy = true;
services.clightning.bind-addr = "127.0.0.1:9735"; services.clightning.bind-addr = "127.0.0.1:9735";
@ -153,7 +127,6 @@ in {
}; };
}; };
services.liquidd.enable = cfg.modules == "all";
services.liquidd.rpcuser = "liquidrpc"; services.liquidd.rpcuser = "liquidrpc";
services.liquidd.prune = 1000; services.liquidd.prune = 1000;
services.liquidd.extraConfig = " services.liquidd.extraConfig = "
@ -170,13 +143,7 @@ in {
version = 3; version = 3;
}; };
services.lightning-charge.enable = cfg.modules == "all";
services.nanopos.enable = cfg.modules == "all";
services.nix-bitcoin-webindex.enable = cfg.modules == "all";
services.clightning.autolisten = cfg.modules == "all";
services.spark-wallet.enable = cfg.modules == "all";
services.spark-wallet.onion-service = true; services.spark-wallet.onion-service = true;
services.electrs.enable = false;
services.electrs.port = 50001; services.electrs.port = 50001;
services.electrs.high-memory = false; services.electrs.high-memory = false;
services.tor.hiddenServices.electrs = { services.tor.hiddenServices.electrs = {
@ -185,7 +152,20 @@ in {
}]; }];
version = 3; version = 3;
}; };
environment.systemPackages = if (cfg.modules == "all") then (minimalPackages ++ allPackages) else minimalPackages; environment.systemPackages = with pkgs; [
tor
bitcoin
nodeinfo
banlist
jq
]
++ optionals config.services.clightning.enable [clightning]
++ optionals config.services.lightning-charge.enable [lightning-charge]
++ optionals config.services.nanopos.enable [nanopos]
++ optionals config.services.nix-bitcoin-webindex.enable [nginx]
++ optionals config.services.liquidd.enable [liquidd]
++ optionals config.services.spark-wallet.enable [spark-wallet]
++ optionals config.services.electrs.enable [electrs];
}; };
} }