forked from hswaw/hscloud
hswaw/sound: add spejsiot-api
Change-Id: If40cdbeadb570d8c33b4c950482c01f4b2bbd1c4 Reviewed-on: https://gerrit.hackerspace.pl/c/hscloud/+/1446 Reviewed-by: vuko <vuko@hackerspace.pl>
This commit is contained in:
parent
aa7303ec45
commit
f0ab6c498a
2 changed files with 65 additions and 0 deletions
|
@ -31,6 +31,7 @@ in {
|
|||
imports =
|
||||
[
|
||||
./hardware-configuration.nix
|
||||
./spejsiot-api.nix
|
||||
];
|
||||
|
||||
boot.loader.systemd-boot.enable = true;
|
||||
|
@ -146,6 +147,30 @@ in {
|
|||
proxyPass = "http://localhost:8123";
|
||||
};
|
||||
};
|
||||
"spejsiot.waw.hackerspace.pl" = {
|
||||
serverAliases = ["default_server"];
|
||||
listen = [
|
||||
{
|
||||
addr = networks.lan.ipv4;
|
||||
port = 80;
|
||||
ssl = false;
|
||||
}
|
||||
];
|
||||
locations."/" = {
|
||||
# TODO copied from iot, are all headers needed?
|
||||
extraConfig = ''
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $http_connection;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Host $host:$server_port;
|
||||
proxy_set_header X-Forwarded-Server $host;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
'';
|
||||
proxyPass = "http://localhost:5100";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
|
40
hswaw/machines/sound.waw.hackerspace.pl/spejsiot-api.nix
Normal file
40
hswaw/machines/sound.waw.hackerspace.pl/spejsiot-api.nix
Normal file
|
@ -0,0 +1,40 @@
|
|||
{ pkgs, workspace, ... }:
|
||||
|
||||
let
|
||||
python = pkgs.python3.withPackages (pp: [ pp.jinja2 pp.paho-mqtt pp.flask ]);
|
||||
src = pkgs.fetchgit {
|
||||
url = "https://code.hackerspace.pl/informatic/spejsiot-api";
|
||||
rev = "d5bcb860738df0c9702c2e6f6954cfa08e3c7153";
|
||||
sha256 = "sha256-1xZ6RKl/AkMYvyFDcANQiSY3dJPQitaKjLl9ijrAHOs=";
|
||||
};
|
||||
run = pkgs.writeShellScriptBin "spejsiot-api" ''
|
||||
cd ${src}
|
||||
exec ${python}/bin/python3 main.py
|
||||
'';
|
||||
|
||||
name = "spejsiot-api";
|
||||
user = name;
|
||||
group = name;
|
||||
socket_dir = "/run/${name}/";
|
||||
in {
|
||||
users.users."${user}" = {
|
||||
group = "${group}";
|
||||
isSystemUser = true;
|
||||
};
|
||||
users.groups."${group}" = { };
|
||||
|
||||
systemd.services."${name}" = {
|
||||
description = "Hackerspace Checkinator";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "mosquitto.service" ];
|
||||
|
||||
serviceConfig.User = "${user}";
|
||||
serviceConfig.Type = "simple";
|
||||
|
||||
serviceConfig.Restart = "always";
|
||||
serviceConfig.RestartSec = "30";
|
||||
|
||||
serviceConfig.ExecStart = "${run}/bin/spejsiot-api";
|
||||
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue