Move webindex in own module

This commit is contained in:
Jonas Nick 2018-12-01 21:38:08 +00:00
parent 8fae70b80a
commit 36327ae89e
2 changed files with 8 additions and 70 deletions

View File

@ -4,37 +4,6 @@ with lib;
let let
cfg = config.services.nixbitcoin; cfg = config.services.nixbitcoin;
indexFile = pkgs.writeText "index.html" ''
<html>
<body>
<p>
<h1>
nix-bitcoin
</h1>
</p>
<p>
<h2>
<a href="store/">store</a>
</h2>
</p>
<p>
<h3>
lightning node: CLIGHTNING_ID
</h3>
</p>
</body>
</html>
'';
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 { in {
imports = imports =
[ [
@ -43,6 +12,7 @@ in {
./clightning.nix ./clightning.nix
./lightning-charge.nix ./lightning-charge.nix
./nanopos.nix ./nanopos.nix
./nixbitcoin-webindex.nix
]; ];
options.services.nixbitcoin = { options.services.nixbitcoin = {
@ -97,45 +67,7 @@ in {
services.lightning-charge.enable = true; services.lightning-charge.enable = true;
services.nanopos.enable = true; services.nanopos.enable = true;
services.nixbitcoin-webindex.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";
};
};
# nodeinfo # nodeinfo
systemd.services.nodeinfo = { systemd.services.nodeinfo = {

View File

@ -10,3 +10,9 @@ echo BITCOIND_ONION="$BITCOIND_ONION"
echo CLIGHTNING_NODEID="$CLIGHTNING_NODEID" echo CLIGHTNING_NODEID="$CLIGHTNING_NODEID"
echo CLIGHTNING_ONION="$CLIGHTNING_ONION" echo CLIGHTNING_ONION="$CLIGHTNING_ONION"
echo CLIGHTNING_ID="$CLIGHTNING_ID" 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