2019-07-11 07:35:36 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
pkg = pkgs.callPackage (
|
|
|
|
pkgs.fetchgit {
|
|
|
|
url = "https://git.shackspace.de/rz/muellshack";
|
2020-01-15 08:11:03 +00:00
|
|
|
rev = "dc80cf1edaa3d86ec2bebae8596ad1d4c4e3650a";
|
|
|
|
sha256 = "1yipr66zhrg5m20pf3rzvgvvl78an6ddkq6zc45rxb2r0i7ipkyh";
|
|
|
|
|
2019-10-28 06:38:07 +00:00
|
|
|
}) { mkYarnPackage = pkgs.yarn2nix-moretea.mkYarnPackage; };
|
2019-07-11 07:35:36 +00:00
|
|
|
home = "/var/lib/muellshack";
|
|
|
|
port = "8081";
|
|
|
|
in {
|
|
|
|
users.users.muellshack = {
|
|
|
|
inherit home;
|
2021-06-05 17:13:25 +00:00
|
|
|
isSystemUser = true;
|
2019-07-11 07:35:36 +00:00
|
|
|
createHome = true;
|
|
|
|
};
|
|
|
|
services.nginx.virtualHosts."muell.shack" = {
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://localhost:${port}/muellshack/";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
services.nginx.virtualHosts."openhab.shack" = {
|
2019-07-16 16:57:09 +00:00
|
|
|
locations."/muellshack/".proxyPass = "http://localhost:${port}/muellshack/";
|
2019-07-11 07:35:36 +00:00
|
|
|
};
|
|
|
|
systemd.services.muellshack = {
|
|
|
|
description = "muellshack";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
environment.PORT = port;
|
|
|
|
serviceConfig = {
|
|
|
|
User = "muellshack";
|
|
|
|
# do not override the current storage fil
|
|
|
|
ExecStartPre = pkgs.writeDash "call-muell-pre" ''
|
|
|
|
cp -vf ${pkg}/share/static_muelldata.json ${home}
|
|
|
|
cp -vn ${pkg}/share/storage.json ${home}
|
2019-07-11 16:11:22 +00:00
|
|
|
chmod 700 ${home}/storage.json
|
2019-07-11 07:35:36 +00:00
|
|
|
'';
|
|
|
|
WorkingDirectory = home;
|
|
|
|
ExecStart = "${pkg}/bin/muellshack";
|
|
|
|
PrivateTmp = true;
|
2019-09-26 19:46:14 +00:00
|
|
|
Restart = "always";
|
|
|
|
RestartSec = "15";
|
2019-07-11 07:35:36 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|