From 36327ae89e85d74e3a6b894d5feb8ce44a0448b9 Mon Sep 17 00:00:00 2001
From: Jonas Nick
Date: Sat, 1 Dec 2018 21:38:08 +0000
Subject: [PATCH] Move webindex in own module
---
modules/nixbitcoin.nix | 72 ++----------------------------------------
pkgs/nodeinfo.sh | 6 ++++
2 files changed, 8 insertions(+), 70 deletions(-)
diff --git a/modules/nixbitcoin.nix b/modules/nixbitcoin.nix
index 2a2e58e..13aceed 100644
--- a/modules/nixbitcoin.nix
+++ b/modules/nixbitcoin.nix
@@ -4,37 +4,6 @@ with lib;
let
cfg = config.services.nixbitcoin;
- indexFile = pkgs.writeText "index.html" ''
-
-
-
-
- nix-bitcoin
-
-
-
-
-
-
-
- lightning node: CLIGHTNING_ID
-
-
-
-
- '';
- createWebIndex = pkgs.writeText "make-index.sh" ''
- set -e
- mkdir -p /var/www/
- cp ${indexFile} /var/www/index.html
- chown -R nginx /var/www/
- nodeinfo
- . <(nodeinfo)
- sed -i "s/CLIGHTNING_ID/$CLIGHTNING_ID/g" /var/www/index.html
- '';
-
in {
imports =
[
@@ -43,6 +12,7 @@ in {
./clightning.nix
./lightning-charge.nix
./nanopos.nix
+ ./nixbitcoin-webindex.nix
];
options.services.nixbitcoin = {
@@ -97,45 +67,7 @@ in {
services.lightning-charge.enable = true;
services.nanopos.enable = true;
-
- services.nginx = {
- enable = true;
- virtualHosts."_" = {
- root = "/var/www";
- extraConfig = ''
- location /store/ {
- proxy_pass http://127.0.0.1:${toString config.services.nanopos.port};
- rewrite /store/(.*) /$1 break;
- }
- '';
- };
-
-
- };
- services.tor.hiddenServices.nginx = {
- map = [{
- port = 80;
- } {
- port = 443;
- }];
- version = 3;
- };
-
- # create-web-index
- systemd.services.create-web-index = {
- description = "Get node info";
- wantedBy = [ "multi-user.target" ];
- after = [ "nodeinfo.service" ];
- path = [ pkgs.nodeinfo pkgs.clightning pkgs.jq pkgs.sudo ];
- serviceConfig = {
- ExecStart="${pkgs.bash}/bin/bash ${createWebIndex}";
- User = "root";
- Type = "simple";
- RemainAfterExit="yes";
- Restart = "on-failure";
- RestartSec = "10s";
- };
- };
+ services.nixbitcoin-webindex.enable = true;
# nodeinfo
systemd.services.nodeinfo = {
diff --git a/pkgs/nodeinfo.sh b/pkgs/nodeinfo.sh
index ed4e4cf..4dfd115 100644
--- a/pkgs/nodeinfo.sh
+++ b/pkgs/nodeinfo.sh
@@ -10,3 +10,9 @@ echo BITCOIND_ONION="$BITCOIND_ONION"
echo CLIGHTNING_NODEID="$CLIGHTNING_NODEID"
echo CLIGHTNING_ONION="$CLIGHTNING_ONION"
echo CLIGHTNING_ID="$CLIGHTNING_ID"
+
+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