From a741e523a002dce3fad4f0bce0f9b5d4552f66ac Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Sat, 14 Dec 2024 21:43:55 +0100 Subject: [PATCH] Package ntfy-sh as NixNG image --- README.md | 2 +- flake.lock | 11 ++++++----- flake.nix | 2 +- images/ntfy-sh.nix | 31 +++++++++++++++++++++++++++++++ modules/ntfy.nix | 24 +++--------------------- 5 files changed, 42 insertions(+), 28 deletions(-) create mode 100644 images/ntfy-sh.nix diff --git a/README.md b/README.md index bddfef9..dbff4fd 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Legend: | --- | --- | --- | | ✨ | `nixng-dnsmasq` | | | ✨ | `nixng-attic` | | +| ✨ | `nixng-ntfy-sh` | | | ✨ | `git.kun.is/home/blog-pim` | | | ✅ | `jellyfin/jellyfin` | | | ✅ | `linuxserver/deluge` | | @@ -39,7 +40,6 @@ Legend: | ✅ | `freshrss/freshrss` | | | ✅ | `ubuntu/bind9` | | | ✅ | `quay.io/hedgedoc/hedgedoc` | | -| ✅ | `binwiederhier/ntfy` | | | 🫤 | `itzg/minecraft-server` | | | 🫤 | `teddysun/kms` | | | 🫤 | `tomsquest/docker-radicale` | | diff --git a/flake.lock b/flake.lock index ac9ed15..1610aad 100644 --- a/flake.lock +++ b/flake.lock @@ -595,15 +595,16 @@ "treefmt-nix": "treefmt-nix_2" }, "locked": { - "lastModified": 1734101800, - "narHash": "sha256-wqEGpgd8bya9giHzrBKjlqUOEvaWr5nrbXqn4d8/q3E=", - "owner": "nix-community", + "lastModified": 1734195137, + "narHash": "sha256-BO6DzwWe2U8FHSxavnFzKHZgobHf2ejI8uu9/AhbHtY=", + "owner": "pizzapim", "repo": "NixNG", - "rev": "45fc112f5c22ad109a80aa153d7d0e00c06503c9", + "rev": "b173ab68cbde3395edda3594d63de4de764f4934", "type": "github" }, "original": { - "owner": "nix-community", + "owner": "pizzapim", + "ref": "ntfy-sh", "repo": "NixNG", "type": "github" } diff --git a/flake.nix b/flake.nix index 763a03a..1eb16c9 100644 --- a/flake.nix +++ b/flake.nix @@ -41,7 +41,7 @@ }; nixng = { - url = "github:nix-community/NixNG"; + url = "github:pizzapim/NixNG/ntfy-sh"; inputs.nixpkgs.follows = "nixpkgs"; }; }; diff --git a/images/ntfy-sh.nix b/images/ntfy-sh.nix new file mode 100644 index 0000000..c272eb2 --- /dev/null +++ b/images/ntfy-sh.nix @@ -0,0 +1,31 @@ +{ + nglib, + nixpkgs, + ... +}: +nglib.makeSystem { + inherit nixpkgs; + system = "x86_64-linux"; + name = "nixng-ntfy-sh"; + + config = {...}: { + dinit.enable = true; + init.services.ntfy-sh.shutdownOnExit = true; + + services.ntfy-sh = { + enable = true; + + settings = { + base-url = "https://ntfy.kun.is"; + cache-file = "/var/cache/ntfy/cache.db"; + cache-duration = "14d"; + auth-file = "/var/lib/ntfy/user.db"; + auth-default-access = "deny-all"; + attachment-cache-dir = "/var/cache/ntfy-attachments"; + enable-signup = false; + enable-login = true; + visitor-subscription-limit = 100; + }; + }; + }; +} diff --git a/modules/ntfy.nix b/modules/ntfy.nix index 4915e8c..822f801 100644 --- a/modules/ntfy.nix +++ b/modules/ntfy.nix @@ -1,25 +1,14 @@ { lib, config, - globals, + utils, + self, ... }: { options.ntfy.enable = lib.mkEnableOption "ntfy"; config = lib.mkIf config.ntfy.enable { kubernetes.resources = { - configMaps.ntfy.data.config = lib.generators.toYAML {} { - base-url = "https://ntfy.kun.is"; - cache-file = "/var/cache/ntfy/cache.db"; - cache-duration = "14d"; - auth-file = "/var/lib/ntfy/user.db"; - auth-default-access = "deny-all"; - attachment-cache-dir = "/var/cache/ntfy-attachments"; - enable-signup = false; - enable-login = true; - visitor-subscription-limit = 100; - }; - deployments.ntfy.spec = { selector.matchLabels.app = "ntfy"; @@ -37,10 +26,9 @@ spec = { containers.ntfy = { - image = globals.images.ntfy; + image = utils.nixSnapshotterRef (utils.mkNixNGImage "ntfy-sh" "${self}/images/ntfy-sh.nix"); ports.web.containerPort = 80; env.TZ.value = "Europe/Amsterdam"; - args = ["serve"]; volumeMounts = [ { @@ -55,11 +43,6 @@ name = "attachment-cache"; mountPath = "/var/cache/ntfy-attachments"; } - { - name = "config"; - mountPath = "/etc/ntfy/server.yml"; - subPath = "config"; - } ]; }; @@ -67,7 +50,6 @@ cache.persistentVolumeClaim.claimName = "cache"; attachment-cache.persistentVolumeClaim.claimName = "attachment-cache"; data.persistentVolumeClaim.claimName = "data"; - config.configMap.name = "ntfy"; }; }; };