hswaw/machines/customs: rework checkinator build
Change-Id: I4ec569c5966f65f46f48a3707842a1fe9d483e16
Reviewed-on: https://gerrit.hackerspace.pl/c/hscloud/+/1171
Reviewed-by: informatic <informatic@hackerspace.pl>
diff --git a/hswaw/machines/customs.hackerspace.pl/checkinator-tracker.nix b/hswaw/machines/customs.hackerspace.pl/checkinator-tracker.nix
index 74617c7..17a9b17 100644
--- a/hswaw/machines/customs.hackerspace.pl/checkinator-tracker.nix
+++ b/hswaw/machines/customs.hackerspace.pl/checkinator-tracker.nix
@@ -1,14 +1,7 @@
{ pkgs, ... }:
let
- old-pkgs = import (fetchTarball {
- sha256 = "0kdx3pz0l422d0vvvj3h8mnq65jcg2scb13dc1z1lg2a8cln842z";
- url = https://api.github.com/repos/NixOS/nixpkgs/tarball/0bf298df24f721a7f85c580339fb7eeff64b927c;
- }) { config = pkgs.config; };
-
- repo = pkgs.fetchgit (builtins.fromJSON
- (builtins.readFile ./checkinator-repo.json));
- checkinator = old-pkgs.callPackage "${repo}/default.nix" {};
+ checkinator = pkgs.callPackage ./checkinator.nix {};
name = "checkinator-tracker";
user = name;
diff --git a/hswaw/machines/customs.hackerspace.pl/checkinator-web.nix b/hswaw/machines/customs.hackerspace.pl/checkinator-web.nix
index 26da702..9165575 100644
--- a/hswaw/machines/customs.hackerspace.pl/checkinator-web.nix
+++ b/hswaw/machines/customs.hackerspace.pl/checkinator-web.nix
@@ -1,23 +1,16 @@
{ pkgs, ... }:
let
- old-pkgs = import (fetchTarball {
- sha256 = "0kdx3pz0l422d0vvvj3h8mnq65jcg2scb13dc1z1lg2a8cln842z";
- url = https://api.github.com/repos/NixOS/nixpkgs/tarball/0bf298df24f721a7f85c580339fb7eeff64b927c;
- }) { config = pkgs.config; };
-
- repo = pkgs.fetchgit (builtins.fromJSON
- (builtins.readFile ./checkinator-repo.json));
- checkinator = old-pkgs.callPackage "${repo}/default.nix" {};
+ checkinator = pkgs.callPackage ./checkinator.nix {};
name = "checkinator-web";
user = name;
group = name;
socket_dir = "/run/${name}/";
- python = old-pkgs.python3.withPackages (ppackages: with ppackages; [
+ python = pkgs.python3.withPackages (ppackages: with ppackages; [
checkinator
- old-pkgs.python3Packages.gunicorn
+ pkgs.python3Packages.gunicorn
]);
prepare = pkgs.writeShellScriptBin "${name}-prepare" ''
@@ -101,7 +94,7 @@
"${pkgs.writeShellScript "checkinator-dbsetup" ''
if [ ! -e "/var/checkinator-web/at.db" ]
then
- ${pkgs.sqlite}/bin/sqlite3 /var/checkinator-web/at.db < ${repo}/dbsetup.sql
+ ${pkgs.sqlite}/bin/sqlite3 /var/checkinator-web/at.db < ${checkinator}/dbsetup.sql
fi
''}"
];
@@ -118,7 +111,7 @@
enableACME = true;
locations."/static/" = {
- alias = "${repo}/static/";
+ alias = "${checkinator}/static/";
};
locations."/" = {
proxyPass = "http://unix://${socket_dir}/web.sock";
diff --git a/hswaw/machines/customs.hackerspace.pl/checkinator-werkzeug.patch b/hswaw/machines/customs.hackerspace.pl/checkinator-werkzeug.patch
new file mode 100644
index 0000000..7517a68
--- /dev/null
+++ b/hswaw/machines/customs.hackerspace.pl/checkinator-werkzeug.patch
@@ -0,0 +1,13 @@
+diff --git a/at/web.py b/at/web.py
+index 34b6337..9eb5e6a 100644
+--- a/at/web.py
++++ b/at/web.py
+@@ -54,7 +54,7 @@ def app(instance_path, devices_api, config):
+ app.updater = devices_api
+
+ if app.config.get('PROXY_FIX'):
+- from werkzeug.contrib.fixers import ProxyFix
++ from werkzeug.middleware.proxy_fix import ProxyFix
+ app.wsgi_app = ProxyFix(app.wsgi_app)
+
+ app.space_auth = SpaceAuth(app)
diff --git a/hswaw/machines/customs.hackerspace.pl/checkinator.nix b/hswaw/machines/customs.hackerspace.pl/checkinator.nix
new file mode 100644
index 0000000..4135f7a
--- /dev/null
+++ b/hswaw/machines/customs.hackerspace.pl/checkinator.nix
@@ -0,0 +1,39 @@
+{ pkgs }:
+
+let
+ spaceauth = pkgs.callPackage "${pkgs.fetchgit {
+ url = "https://code.hackerspace.pl/informatic/flask-spaceauth";
+ rev = "d3e1a4412cbc929249e407ccecfb54fbbd14e53a";
+ sha256 = "01qnjj647jw81hcyvq359rwqjpc5ah9ghvc6ic0a0wppp13mgw94";
+ }}" {};
+in pkgs.python3Packages.buildPythonPackage {
+ pname = "checkinator";
+ version = "0.2";
+
+ doCheck = false;
+ src = pkgs.fetchgit (builtins.fromJSON (builtins.readFile ./checkinator-repo.json));
+
+ patches = [
+ ./checkinator-werkzeug.patch
+ ];
+
+ postInstall = ''
+ cp -r dbsetup.sql $out/dbsetup.sql
+ cp -r static $out/static
+ '';
+
+ propagatedBuildInputs = with pkgs; [
+ python3Packages.gunicorn
+ python3Packages.flask
+ python3Packages.pyyaml
+ python3Packages.isodate
+ python3Packages.requests
+ python3Packages.requests-unixsocket
+ python3Packages.grpcio
+ python3Packages.grpcio-tools
+ python3Packages.setuptools
+ python3Packages.protobuf
+ spaceauth
+ iproute
+ ];
+}