Add 'minimal' and 'all' profiles

This commit is contained in:
Jonas Nick 2018-12-03 15:31:44 +00:00
parent da1148595f
commit 4c55b8395c
3 changed files with 34 additions and 19 deletions

View File

@ -16,7 +16,7 @@ in {
./modules/nixbitcoin.nix ./modules/nixbitcoin.nix
]; ];
# turn off binary cache by setting binaryCaches to empty list # Turn off binary cache by setting binaryCaches to empty list
# nix.binaryCaches = []; # nix.binaryCaches = [];
networking.hostName = "nix-bitcoin"; # Define your hostname. networking.hostName = "nix-bitcoin"; # Define your hostname.
@ -35,6 +35,8 @@ in {
services.openssh.enable = true; services.openssh.enable = true;
networking.firewall.enable = true; networking.firewall.enable = true;
services.nixbitcoin.enable = true; services.nixbitcoin.enable = true;
# Install and use minimal or all modules
services.nixbitcoin.modules = "all";
# This value determines the NixOS release with which your system is to be # This value determines the NixOS release with which your system is to be
# compatible, in order to avoid breaking some software such as database # compatible, in order to avoid breaking some software such as database

View File

@ -188,6 +188,7 @@ in {
fi fi
cp '${configFile}' '${cfg.dataDir}/bitcoin.conf' cp '${configFile}' '${cfg.dataDir}/bitcoin.conf'
chmod o-rw '${cfg.dataDir}/bitcoin.conf' chmod o-rw '${cfg.dataDir}/bitcoin.conf'
chown '${cfg.user}:${cfg.group}' '${cfg.dataDir}/bitcoin.conf'
echo "rpcpassword=$(cat /secrets/bitcoin-rpcpassword)" >> '${cfg.dataDir}/bitcoin.conf' echo "rpcpassword=$(cat /secrets/bitcoin-rpcpassword)" >> '${cfg.dataDir}/bitcoin.conf'
''; '';
serviceConfig = { serviceConfig = {

View File

@ -4,6 +4,18 @@ with lib;
let let
cfg = config.services.nixbitcoin; cfg = config.services.nixbitcoin;
minimalPackages = with pkgs; [
bitcoin
clightning
nodeinfo
jq
];
allPackages = with pkgs; [
lightning-charge.package
nanopos.package
nodejs-8_x
nginx
];
in { in {
imports = imports =
[ [
@ -24,22 +36,16 @@ 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 {
environment.systemPackages = with pkgs; [
vim tmux clightning bitcoin
nodeinfo
jq
lightning-charge.package
nanopos.package
nodejs-8_x
nginx
];
# Add bitcoinrpc group
users.groups.bitcoinrpc = {};
# Tor # Tor
services.tor.enable = true; services.tor.enable = true;
services.tor.client.enable = true; services.tor.client.enable = true;
@ -63,6 +69,9 @@ in {
version = 3; version = 3;
}; };
# Add bitcoinrpc group
users.groups.bitcoinrpc = {};
# clightning # clightning
services.clightning = { services.clightning = {
enable = true; enable = true;
@ -75,11 +84,6 @@ in {
version = 3; version = 3;
}; };
services.lightning-charge.enable = true;
services.nanopos.enable = true;
services.nixbitcoin-webindex.enable = true;
# Create user operator which can use bitcoin-cli and lightning-cli # Create user operator which can use bitcoin-cli and lightning-cli
users.users.operator = { users.users.operator = {
isNormalUser = true; isNormalUser = true;
@ -107,6 +111,14 @@ in {
type = "oneshot"; type = "oneshot";
}; };
}; };
# This is required to have the deployment keys copied and chowned even if
# nanopos is not enabled
users.users.nanopos = {};
users.groups.nanopos = {};
services.lightning-charge.enable = cfg.modules == "all";
services.nanopos.enable = cfg.modules == "all";
services.nixbitcoin-webindex.enable = cfg.modules == "all";
environment.systemPackages = if (cfg.modules == "all") then (minimalPackages ++ allPackages) else minimalPackages;
}; };
} }