From 528ef9ab77b91b24cd7961ff99e8975b1e35a9b3 Mon Sep 17 00:00:00 2001 From: kurogeek Date: Wed, 16 Jul 2025 16:06:37 +0700 Subject: [PATCH] stirling-pdf service --- inventories/default.nix | 8 +++++ modules/clan/stirling-pdf/default.nix | 48 +++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 modules/clan/stirling-pdf/default.nix diff --git a/inventories/default.nix b/inventories/default.nix index dbd953b..a133d01 100644 --- a/inventories/default.nix +++ b/inventories/default.nix @@ -10,6 +10,7 @@ modules = { pocket-id = ../modules/clan/pocket-id; nextcloud = ../modules/clan/nextcloud; + stirling-pdf = ../modules/clan/stirling-pdf; }; inventory = { @@ -30,6 +31,13 @@ roles.default.machines.b4l = { }; }; + stirling-pdf = { + module = { + name = "stirling-pdf"; + input = "self"; + }; + roles.default.machines.b4l = { }; + }; }; services = { diff --git a/modules/clan/stirling-pdf/default.nix b/modules/clan/stirling-pdf/default.nix new file mode 100644 index 0000000..93427c8 --- /dev/null +++ b/modules/clan/stirling-pdf/default.nix @@ -0,0 +1,48 @@ +{ lib, ... }: +{ + _class = "clan.service"; + manifest.name = "stirling-pdf"; + manifest.description = "Your locally hosted one-stop-shop for all your PDF needs."; + manifest.categories = [ "System" ]; + + roles.default = { + interface.options = { + domain = lib.mkOption { + type = lib.types.str; + default = "pdf"; + description = "Sub domain or Stirling PDF service"; + }; + }; + + perInstance = + { + settings, + ... + }: + { + nixosModule = + { + config, + ... + }: + let + domain = "${settings.domain}.${config.networking.fqdn}"; + in + { + services.stirling-pdf = { + enable = true; + environment = { + SERVER_PORT = 8080; + }; + }; + services.nginx.virtualHosts."${domain}" = { + forceSSL = true; + useACMEHost = "${config.networking.fqdn}"; + locations."/" = { + proxyPass = "http://localhost:${builtins.toString config.services.stirling-pdf.environment.SERVER_PORT}"; + }; + }; + }; + }; + }; +}