From bdb02a607cec416dd9641b81fb160e94698c3197 Mon Sep 17 00:00:00 2001 From: Alejandro Soto Date: Mon, 11 Sep 2023 00:45:52 -0600 Subject: [PATCH] trivios: add web services --- triviOS/default.nix | 2 +- triviOS/web.nix | 35 +++++++++++++++++++++++++++++++++++ ui/default.nix | 9 +++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 triviOS/web.nix create mode 100644 ui/default.nix diff --git a/triviOS/default.nix b/triviOS/default.nix index 770f434..f57b402 100644 --- a/triviOS/default.nix +++ b/triviOS/default.nix @@ -10,6 +10,7 @@ imports = [ (modulesPath + "/installer/sd-card/sd-image-aarch64.nix") (modulesPath + "/profiles/minimal.nix") + ./web.nix ]; disabledModules = [ @@ -31,7 +32,6 @@ hardware.enableRedistributableFirmware = true; environment.systemPackages = with pkgs; [ libraspberrypi - (python3.withPackages (py: [ py.django ])) ]; networking.wireless.enable = true; networking.hostName = "tripi"; diff --git a/triviOS/web.nix b/triviOS/web.nix new file mode 100644 index 0000000..c17687b --- /dev/null +++ b/triviOS/web.nix @@ -0,0 +1,35 @@ +{ config, pkgs, ... }: { + config.services = { + nginx = { + enable = true; + + recommendedGzipSettings = true; + recommendedOptimisation = true; + recommendedProxySettings = true; + + virtualHosts.home-manager = { + default = true; + + locations = { + "/".extraConfig = '' + uwsgi_pass unix://${config.services.uwsgi.runDir}/uwsgi.sock; + include uwsgi_params; + ''; + }; + }; + }; + + uwsgi = { + enable = true; + group = "nginx"; + plugins = [ "python3" ]; + + instance = { + type = "normal"; + pythonPackages = py: [ py.callPackage ../ui { } ]; + + module = "homemanager.wsgi"; + }; + }; + }; +} diff --git a/ui/default.nix b/ui/default.nix new file mode 100644 index 0000000..6797106 --- /dev/null +++ b/ui/default.nix @@ -0,0 +1,9 @@ +{ buildPythonPackage, django_4 }: +buildPythonPackage { + pname = "homemanager"; + version = "0.0.1"; + + src = ./.; + + propagatedBuildInputs = [ django_4 ]; +}