{
  lib,
  config,
  utils,
  ...
}: {
  options.ntfy.enable = lib.mkEnableOption "ntfy";

  config = lib.mkIf config.ntfy.enable {
    kubernetes.resources = {
      deployments.ntfy.spec = {
        selector.matchLabels.app = "ntfy";

        strategy = {
          type = "RollingUpdate";

          rollingUpdate = {
            maxSurge = 0;
            maxUnavailable = 1;
          };
        };

        template = {
          metadata.labels.app = "ntfy";

          spec = {
            nodeName = "jefke";

            containers.ntfy = {
              image = utils.mkNixNGImage "ntfy";
              ports.web.containerPort = 80;
              env.TZ.value = "Europe/Amsterdam";

              volumeMounts = [
                {
                  name = "cache";
                  mountPath = "/var/cache/ntfy";
                }
                {
                  name = "data";
                  mountPath = "/var/lib/ntfy";
                }
                {
                  name = "attachment-cache";
                  mountPath = "/var/cache/ntfy-attachments";
                }
              ];
            };

            volumes = {
              cache.persistentVolumeClaim.claimName = "cache";
              attachment-cache.persistentVolumeClaim.claimName = "attachment-cache";

              data.hostPath = {
                path = "/mnt/longhorn/persistent/volumes/ntfy";
                type = "Directory";
              };
            };

            securityContext = {
              fsGroup = 407;
              fsGroupChangePolicy = "Always";
            };
          };
        };
      };

      persistentVolumeClaims = {
        cache.spec = {
          accessModes = ["ReadWriteOnce"];
          resources.requests.storage = "300Mi";
        };

        attachment-cache.spec = {
          accessModes = ["ReadWriteOnce"];
          resources.requests.storage = "500Mi";
        };
      };

      services.ntfy.spec = {
        selector.app = "ntfy";

        ports.web = {
          port = 80;
          targetPort = "web";
        };
      };
    };

    lab = {
      ingresses.ntfy = {
        host = "ntfy.kun.is";

        service = {
          name = "ntfy";
          portName = "web";
        };
      };
    };
  };
}