From 8007a6de7f973e467918540b9c9a44743dc46581 Mon Sep 17 00:00:00 2001 From: derped Date: Mon, 26 Feb 2024 17:21:14 +0100 Subject: [PATCH] Add tandoor service. --- machines/Ophanim/options.nix | 5 +++++ services/nginx_vHosts/tandoor.nix | 29 +++++++++++++++++++++++++++++ services/tandoor.nix | 16 ++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 services/nginx_vHosts/tandoor.nix create mode 100644 services/tandoor.nix diff --git a/machines/Ophanim/options.nix b/machines/Ophanim/options.nix index f6d90cf..98e6ed6 100644 --- a/machines/Ophanim/options.nix +++ b/machines/Ophanim/options.nix @@ -34,6 +34,7 @@ in { services = [ "acme" "gitea" + "tandoor" # "hydra" "mailserver" "mariaDB" @@ -62,6 +63,10 @@ in { domain = "git.${base}"; service = "gitea"; } + { + domain = "food.${base}"; + service = "tandoor"; + } ]; firewall = { enable = true; diff --git a/services/nginx_vHosts/tandoor.nix b/services/nginx_vHosts/tandoor.nix new file mode 100644 index 0000000..b2c4f53 --- /dev/null +++ b/services/nginx_vHosts/tandoor.nix @@ -0,0 +1,29 @@ +{ + config, + lib, + ... +}: +with lib; +let + tandoor = config.services.tandoor-recipes; +in { + vHost = + if tandoor.enable + then { + extraConfig = '' + location /media/ { + alias ${tandoor.extraConfig.MEDIA_ROOT}; + } + + location / { + proxy_pass http://${tandoor.address}:${toString tandoor.port}; + proxy_set_header Host $host; + proxy_set_header REMOTE_ADDR $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + ''; + } + else {}; + } + .vHost diff --git a/services/tandoor.nix b/services/tandoor.nix new file mode 100644 index 0000000..0965578 --- /dev/null +++ b/services/tandoor.nix @@ -0,0 +1,16 @@ +{ + config, + lib, + pkgs, + ... +}: +with lib; + mkIf (elem "tandoor" config.machine.services) { + services.tandoor-recipes = { + enable = true; + extraConfig = { + # Set explicitly so it can be referenced by web-server + MEDIA_ROOT = "/var/lib/tandoor-recipes/media/"; + }; + }; + }