Package ntfy-sh as NixNG image

This commit is contained in:
Pim Kunis 2024-12-14 21:43:55 +01:00
parent 23e8146077
commit a741e523a0
5 changed files with 42 additions and 28 deletions

View file

@ -13,6 +13,7 @@ Legend:
| --- | --- | --- | | --- | --- | --- |
| ✨ | `nixng-dnsmasq` | | | ✨ | `nixng-dnsmasq` | |
| ✨ | `nixng-attic` | | | ✨ | `nixng-attic` | |
| ✨ | `nixng-ntfy-sh` | |
| ✨ | `git.kun.is/home/blog-pim` | | | ✨ | `git.kun.is/home/blog-pim` | |
| ✅ | `jellyfin/jellyfin` | | | ✅ | `jellyfin/jellyfin` | |
| ✅ | `linuxserver/deluge` | | | ✅ | `linuxserver/deluge` | |
@ -39,7 +40,6 @@ Legend:
| ✅ | `freshrss/freshrss` | | | ✅ | `freshrss/freshrss` | |
| ✅ | `ubuntu/bind9` | | | ✅ | `ubuntu/bind9` | |
| ✅ | `quay.io/hedgedoc/hedgedoc` | | | ✅ | `quay.io/hedgedoc/hedgedoc` | |
| ✅ | `binwiederhier/ntfy` | |
| 🫤 | `itzg/minecraft-server` | | | 🫤 | `itzg/minecraft-server` | |
| 🫤 | `teddysun/kms` | | | 🫤 | `teddysun/kms` | |
| 🫤 | `tomsquest/docker-radicale` | | | 🫤 | `tomsquest/docker-radicale` | |

View file

@ -595,15 +595,16 @@
"treefmt-nix": "treefmt-nix_2" "treefmt-nix": "treefmt-nix_2"
}, },
"locked": { "locked": {
"lastModified": 1734101800, "lastModified": 1734195137,
"narHash": "sha256-wqEGpgd8bya9giHzrBKjlqUOEvaWr5nrbXqn4d8/q3E=", "narHash": "sha256-BO6DzwWe2U8FHSxavnFzKHZgobHf2ejI8uu9/AhbHtY=",
"owner": "nix-community", "owner": "pizzapim",
"repo": "NixNG", "repo": "NixNG",
"rev": "45fc112f5c22ad109a80aa153d7d0e00c06503c9", "rev": "b173ab68cbde3395edda3594d63de4de764f4934",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nix-community", "owner": "pizzapim",
"ref": "ntfy-sh",
"repo": "NixNG", "repo": "NixNG",
"type": "github" "type": "github"
} }

View file

@ -41,7 +41,7 @@
}; };
nixng = { nixng = {
url = "github:nix-community/NixNG"; url = "github:pizzapim/NixNG/ntfy-sh";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
}; };

31
images/ntfy-sh.nix Normal file
View file

@ -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;
};
};
};
}

View file

@ -1,25 +1,14 @@
{ {
lib, lib,
config, config,
globals, utils,
self,
... ...
}: { }: {
options.ntfy.enable = lib.mkEnableOption "ntfy"; options.ntfy.enable = lib.mkEnableOption "ntfy";
config = lib.mkIf config.ntfy.enable { config = lib.mkIf config.ntfy.enable {
kubernetes.resources = { 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 = { deployments.ntfy.spec = {
selector.matchLabels.app = "ntfy"; selector.matchLabels.app = "ntfy";
@ -37,10 +26,9 @@
spec = { spec = {
containers.ntfy = { containers.ntfy = {
image = globals.images.ntfy; image = utils.nixSnapshotterRef (utils.mkNixNGImage "ntfy-sh" "${self}/images/ntfy-sh.nix");
ports.web.containerPort = 80; ports.web.containerPort = 80;
env.TZ.value = "Europe/Amsterdam"; env.TZ.value = "Europe/Amsterdam";
args = ["serve"];
volumeMounts = [ volumeMounts = [
{ {
@ -55,11 +43,6 @@
name = "attachment-cache"; name = "attachment-cache";
mountPath = "/var/cache/ntfy-attachments"; mountPath = "/var/cache/ntfy-attachments";
} }
{
name = "config";
mountPath = "/etc/ntfy/server.yml";
subPath = "config";
}
]; ];
}; };
@ -67,7 +50,6 @@
cache.persistentVolumeClaim.claimName = "cache"; cache.persistentVolumeClaim.claimName = "cache";
attachment-cache.persistentVolumeClaim.claimName = "attachment-cache"; attachment-cache.persistentVolumeClaim.claimName = "attachment-cache";
data.persistentVolumeClaim.claimName = "data"; data.persistentVolumeClaim.claimName = "data";
config.configMap.name = "ntfy";
}; };
}; };
}; };