From e67655e12ae438e71ca85e7a9b63cad1aec93184 Mon Sep 17 00:00:00 2001 From: stupidcomputer Date: Sun, 12 Jan 2025 20:50:31 -0600 Subject: [PATCH] provisional flasktrack commit --- boxes/netbox/default.nix | 1 + boxes/netbox/flasktrack.nix | 28 ++++++++++++++++++++++++++++ builds/flasktrack.nix | 23 +++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 boxes/netbox/flasktrack.nix create mode 100644 builds/flasktrack.nix diff --git a/boxes/netbox/default.nix b/boxes/netbox/default.nix index 817d4ad..c621cae 100644 --- a/boxes/netbox/default.nix +++ b/boxes/netbox/default.nix @@ -5,6 +5,7 @@ ../../lib/bootstrap.nix ./agenix.nix + ./flasktrack.nix ./franklincce.nix ./gitea.nix ./mail.nix diff --git a/boxes/netbox/flasktrack.nix b/boxes/netbox/flasktrack.nix new file mode 100644 index 0000000..f775594 --- /dev/null +++ b/boxes/netbox/flasktrack.nix @@ -0,0 +1,28 @@ +{ pkgs, ... }: +let + appEnv = pkgs.python3.withPackages (p: with p; [ + waitress + (callPackage ../../builds/flasktrack.nix {}) + ]); +in { + systemd.services.flasktrack = { + wantedBy = [ "multi-user.target" ]; + environment = { + FLASKTRACK_CREDENTIAL_LOCATION = "/etc/flasktrack-secrets.cfg"; + }; + serviceConfig = { + ExecStart = "${appEnv}/bin/waitress-serve --port=8042 flasktrack:app"; + StandardOutput = "journal"; + }; + }; + + services.nginx.virtualHosts."flasktrack.beepboop.systems" = { + forceSSL = true; + enableACME = true; + locations."/" = { + extraConfig = '' + proxy_pass http://localhost:8042; + ''; + }; + }; +} diff --git a/builds/flasktrack.nix b/builds/flasktrack.nix new file mode 100644 index 0000000..7d17955 --- /dev/null +++ b/builds/flasktrack.nix @@ -0,0 +1,23 @@ +{ python3Packages, fetchgit }: +with python3Packages; +buildPythonApplication rec { + pname = "flasktrack"; + version = "1.0.0"; + format = "other"; + + propagatedBuildInputs = [ flask ]; + installPhase = '' + runHook preInstall + + mkdir -p $out/${pythonPackages.python.sitePackages} + cp -r ./${pname} $out/${pythonPackages.python.sitePackages}/${pname} + + runHook postInstall + ''; + shellHook = "export FLASK_APP=${pname}"; + + src = fetchgit { + url = "https://git.beepboop.systems/stupidcomputer/flasktrack"; + hash = "sha256-ezR+Y0ciA5+SVEOIWYUtmVxMeNpcVKXOBe1OSgYm0sA="; + }; +}