hopglass: test if hopglass works on nixos

This commit is contained in:
Daniel Frank 2019-08-11 16:25:29 +02:00
parent 7b806690a8
commit c006338aec
Signed by: tokudan
GPG key ID: 063CCCAD04182D32
4 changed files with 129 additions and 0 deletions

View file

@ -14,6 +14,7 @@
./variables.nix ./variables.nix
./mailserver.nix ./mailserver.nix
./borgbackup.nix ./borgbackup.nix
./hopglass-frontend.nix
]; ];
# Configuration options for the mailserver # Configuration options for the mailserver

View file

@ -0,0 +1,63 @@
{
"dataPath": "https://hopglass-backend.hamburg.freifunk.net/",
"siteName": "Freifunk Hamburg",
"mapSigmaScale": 1.1,
"showContact": false,
"maxAge": 30,
"mapLayers": [
{
"name": "OpenStreetMap",
"url": "https://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png",
"config": {
"maxZoom": 18,
"attribution": "&copy; <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a>"
}
},
{
"name": "Satellitenbild",
"url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",
"config": {
"attribution": "Tiles &copy; Esri &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community"
}
},
{
"name": "Stamen (TonerLite)",
"url": "https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}.png",
"config": {
"maxZoom": 20,
"attribution": "Map tiles by <a href=\"https://stamen.com\">Stamen Design</a>, <a href=\"https://creativecommons.org/licenses/by/3.0\">CC BY 3.0</a> &mdash; Map data &copy; <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a>"
}
}
],
"nodeInfos": [
{
"name": "Clientstatistik",
"href": "https://statistik.hamburg.freifunk.net/dashboard/db/freifunk-knoteninfo-knoten-id?var-region=ffhh&var-knoten={NODE_ID}",
"thumbnail": "https://statistik.hamburg.freifunk.net/render/dashboard-solo/db/freifunk-knoteninfo-knoten-id?panelId=1&var-region=ffhh&var-knoten={NODE_ID}&theme=light&width=530&height=332&from=now-3d",
"caption": "Verbundene Clients in den letzten 3 Tage an Knoten {NODE_ID}"
}
],
"globalInfos": [
{
"name": "Clientstatistik (gesamt)",
"href": "https://statistik.hamburg.freifunk.net/dashboard/db/freifunk-ubersicht?var-region=ffhh",
"thumbnail": "https://statistik.hamburg.freifunk.net/render/dashboard-solo/db/freifunk-ubersicht?panelId=1&var-region=ffhh&theme=light&width=530&height=332&from=now-3d",
"caption": "Verbundene Clients in den letzten 3 Tagen"
}
],
"linkInfos": [],
"siteNames": [
{ "site": "ffhh", "name": "Hamburg" },
{ "site": "ffhh-nowe", "name": "Hamburg-NordWest" },
{ "site": "ffhh-ost", "name": "Hamburg-Ost" },
{ "site": "ffhh-sued", "name": "Hamburg-Sued" },
{ "site": "ffhh-west", "name": "Hamburg-West" }
],
"domainNames": [
{ "domain": "ffhh_nowe", "name": "Hamburg-NordWest" },
{ "domain": "ffhh_ost", "name": "Hamburg-Ost" },
{ "domain": "ffhh_sued", "name": "Hamburg-Sued" },
{ "domain": "ffhh_west", "name": "Hamburg-West" }
],
"hwImg": []
}

21
hopglass-frontend.nix Normal file
View file

@ -0,0 +1,21 @@
{ config, lib, pkgs, ... }:
let
hopglass-fe = (pkgs.callPackage ./pkg-hopglass-fe.nix {
conf = ./hopglass-frontend.config.json;
} );
in
{
services.nginx.virtualHosts."map2.hamburg.freifunk.net" = {
forceSSL = true;
enableACME = true;
root = "${hopglass-fe}";
locations."/" = {
extraConfig = ''
index index.html;
etag off;
add_header etag "\"${builtins.substring 11 32 hopglass-fe}\"";
'';
};
};
}

44
pkg-hopglass-fe.nix Normal file
View file

@ -0,0 +1,44 @@
{ stdenv, lib, pkgs, python, nodejs-11_x, fetchFromGitHub, fetchzip, fetchurl, conf }:
let
nodejs = nodejs-11_x;
yarn2nix = import (fetchFromGitHub {
rev = "3f2dbb08724bf8841609f932bfe1d61a78277232";
owner = "moretea";
repo = "yarn2nix";
sha256 = "142av7dwviapsnahgj8r6779gs2zr17achzhr8b97s0hsl08dcl2";
}) { inherit pkgs nodejs; };
origPackage = builtins.fromJSON (builtins.readFile ./package.json);
src = fetchFromGitHub {
rev = "fc09b591dc2b9dd867559ea008f1177d52a824dd";
owner = "hopglass";
repo = "hopglass";
sha256 = "0s9x466jqn7swbd35kjiaqk2lmcy9fnykhcnb1b10a2l35q655cl";
};
in
yarn2nix.mkYarnPackage {
name = "hopglass-frontend";
src = src;
installPhase = ''
echo ---------------------------------------------------------------------------- installPhase
set -x
#yarn --offline build
ls -l
cp -R $src/. .
node_modules/.bin/grunt --force
mkdir -p $out
set +x
'';
distPhase = ''
cp -Rv build/* $out/
ln -s "$conf" $out/config.json
'';
allowedReferences = [ "out" ];
yarnPreBuild = ''
mkdir -p $HOME/.node-gyp/${nodejs.version}
echo 9 > $HOME/.node-gyp/${nodejs.version}/installVersion
ln -sfv ${nodejs}/include $HOME/.node-gyp/${nodejs.version}
'';
# work around some purity problems in nix
#yarnLock = ./yarn.lock;
#packageJSON = ./package.json;
}