Skip to content

Commit

Permalink
Add rpc user and password as secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasnick committed Nov 22, 2018
1 parent 83eabcf commit 79aab12
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
secrets/
3 changes: 0 additions & 3 deletions configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ in {
environment.systemPackages = with pkgs; [
vim tmux clightning bitcoin
nodeinfo
jq
];
nixpkgs.config.packageOverrides = pkgs: {
inherit nodeinfo;
Expand All @@ -48,8 +47,6 @@ in {
#services.bitcoin.proxy = services.tor.client.socksListenAddress;
services.nixbitcoin.enable = true;



# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
Expand Down
16 changes: 16 additions & 0 deletions generate_secrets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

SECRETSFILE=secrets/secrets.nix

if [ -e "$SECRETSFILE" ]; then
echo $SECRETSFILE already exists
exit 1
fi

echo Installing apg through nix-env
nix-env -i apg
echo Creating bitcoin RPC password
echo \{ >> $SECRETSFILE
echo " bitcoinrpcpassword = \"$(apg -m 20 -x 20 -M Ncl -n 1)\";" >> $SECRETSFILE
echo \} >> $SECRETSFILE
echo Done
13 changes: 13 additions & 0 deletions load-secrets.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
if builtins.pathExists ./secrets/secrets.nix then import ./secrets/secrets.nix else {
prophet-openvpn-config = "";
prophet-guest-openvpn-config = "";
centrallake-openvpn-config = "";
bower-openvpn-config = "";
unifi_password_ro = "";
alertmanager_smtp_pw = "";
alertmanager_pushover_user = "";
alertmanager_pushover_token = "";
mpd_pw = "";
mpd_icecast_pw = "";
github_token = "";
}
2 changes: 1 addition & 1 deletion modules/bitcoind.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let
discover=0
${optionalString (cfg.port != null) "port=${toString cfg.port}"}
${optionalString (cfg.rpcuser != null) "rpcuser=${cfg.rpcuser}"}
${optionalString (cfg.rpcpassword != null) "rpcuser=${cfg.rpcpassword}"}
${optionalString (cfg.rpcpassword != null) "rpcpassword=${cfg.rpcpassword}"}
'';
in {
options.services.bitcoin = {
Expand Down
3 changes: 2 additions & 1 deletion modules/nixbitcoin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ with lib;

let
cfg = config.services.nixbitcoin;
secrets = import ../load-secrets.nix;
in {
imports =
[
Expand Down Expand Up @@ -39,7 +40,7 @@ in {
services.bitcoin.proxy = config.services.tor.client.socksListenAddress;
services.bitcoin.port = 8333;
services.bitcoin.rpcuser = "bitcoinrpc";
services.bitcoin.rpcpassword = "bitcoinrpc";
services.bitcoin.rpcpassword = secrets.bitcoinrpcpassword;

# clightning
services.clightning.enable = true;
Expand Down
4 changes: 3 additions & 1 deletion network.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
let
secrets = import ./load-secrets.nix;
in {
network.description = "Bitcoin Core node";

bitcoin-node = import ./configuration.nix;
Expand Down

0 comments on commit 79aab12

Please sign in to comment.