Something went wrong. Try again.
Flake for my desktop, laptop, and my homelab.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138{ flake.aspects.gotify-server.nixos = { # keep-sorted start config, lib, pkgs, vars, # keep-sorted end ... }: let inherit (lib) mkForce;
inherit (pkgs.nur.repos.adam0) gotifyPlugins;
inherit (vars) groundDomain;
templates = config.sops.templates;
gotifyPluginsDrv = pkgs.symlinkJoin { name = "gotify-plugins"; paths = [gotifyPlugins.authentik]; }; in { sops = { secrets = { "gotify/client_id" = {}; "gotify/client_secret" = {}; };
templates."gotify.env".content = '' GOTIFY_OIDC_CLIENTID=${config.sops.placeholder."gotify/client_id"} GOTIFY_OIDC_CLIENTSECRET=${config.sops.placeholder."gotify/client_secret"} ''; };
services.gotify = { enable = true; package = pkgs.nur.repos.adam0.gotify-server; stateDirectoryName = "gotify";
environment = { GOTIFY_SERVER_PORT = 44407; GOTIFY_SERVER_SECURECOOKIE = "true";
GOTIFY_OIDC_ENABLED = "true"; GOTIFY_OIDC_ISSUER = "https://authentik.${groundDomain}/application/o/gotify/"; GOTIFY_OIDC_LINK_BY_USERNAME = "true"; GOTIFY_OIDC_REDIRECTURL = "https://gotify.${groundDomain}/auth/oidc/callback";
GOTIFY_DATABASE_DIALECT = "postgres"; GOTIFY_DATABASE_CONNECTION = "host=/run/postgresql user=gotify dbname=gotify sslmode=disable"; };
environmentFiles = [templates."gotify.env".path]; };
users = { groups.gotify = {};
users.gotify = { group = "gotify"; isSystemUser = true; }; };
networking.firewall.extraInputRules = '' # Allow containers to reach host Gotify. iifname "br-crowdsec" tcp dport 44407 accept iifname "podman*" tcp dport 44407 accept '';
systemd.services.gotify-server = { after = [ # keep-sorted start "authentik-worker.service" "authentik.service" "postgresql.service" "sops-install-secrets.service" "systemd-tmpfiles-setup.service" "traefik.service" # keep-sorted end ];
wants = [ # keep-sorted start "authentik-worker.service" "authentik.service" "postgresql.service" "sops-install-secrets.service" "systemd-tmpfiles-setup.service" "traefik.service" # keep-sorted end ];
unitConfig = { StartLimitBurst = 60; StartLimitIntervalSec = "5min"; };
serviceConfig = { DynamicUser = mkForce false; User = "gotify"; Group = "gotify"; RestartSec = "5s"; }; };
systemd.tmpfiles.rules = ["L+ /var/lib/gotify/data/plugins - - - - ${gotifyPluginsDrv}"];
systemd.services.gotify-optimize-images = { description = "Optimize Gotify uploaded images";
# keep-sorted start after = ["gotify-server.service"]; requires = ["gotify-server.service"]; # keep-sorted end
serviceConfig = { Type = "oneshot"; User = "gotify"; Group = "gotify"; ExecStart = "${pkgs.gotify-optimize-images}/bin/gotify-optimize-images"; }; };
systemd.timers.gotify-optimize-images = { description = "Daily Gotify image optimization";
wantedBy = ["timers.target"];
timerConfig = { OnCalendar = "daily"; Persistent = true; }; }; };}