binwiederhier / ntfy

Send push notifications to your phone or desktop using PUT/POST
https://ntfy.sh
Apache License 2.0
18.64k stars 732 forks source link

Ntfy server is impossible to set up on NixOS 23.11 #1070

Closed KaiserCalm closed 8 months ago

KaiserCalm commented 8 months ago

:lady_beetle: Describe the bug When installing ntfy-sh by enabling it as a module, the state directory is created in /var/lib/private/ntfy-sh and linked to /var/lib/ntfy-sh. This is a problem as the private folder is owned by root which makes the symlink inaccessible. Changing the permissions of the private folder seems to create other problems as ntfy-sh requests the folder be owned by root with permissions 0700 and that makes this problem a Catch-22 as by default ntfy-sh can't access the files in it's state folder and if permissions are changed, ntfy-sh does not want to access it's folder.

:computer: Components impacted ntfy server v2.8.0

:bulb: Screenshots and/or logs Default:

× ntfy-sh.service - Push notifications server
     Loaded: loaded (/etc/systemd/system/ntfy-sh.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Tue 2024-03-26 21:07:07 EET; 1s ago
   Duration: 71ms
    Process: 11056 ExecStart=/nix/store/wgb20j6kkxz0j6d5ihmn9g29giqx6wmp-ntfy-sh-2.8.0/bin/ntfy serve -c /nix/store/ma711yry2gs6s8vsnrah1cy9fx0iipdv-server.yml (code=exited, status=1/FAILURE)
   Main PID: 11056 (code=exited, status=1/FAILURE)
         IP: 0B in, 0B out
        CPU: 69ms

Mar 26 21:07:07 server systemd[1]: Started Push notifications server.
Mar 26 21:07:07 server ntfy[11056]: 2024/03/26 21:07:07 FATAL attempt to write a readonly database (exit_code=1)
Mar 26 21:07:07 server ntfy[11056]: attempt to write a readonly database
Mar 26 21:07:07 server systemd[1]: ntfy-sh.service: Main process exited, code=exited, status=1/FAILURE
Mar 26 21:07:07 server systemd[1]: ntfy-sh.service: Failed with result 'exit-code'.

Too permissive:

× ntfy-sh.service - Push notifications server
     Loaded: loaded (/etc/systemd/system/ntfy-sh.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Tue 2024-03-26 21:03:03 EET; 1s ago
   Duration: 2ms
    Process: 8743 ExecStart=/nix/store/wgb20j6kkxz0j6d5ihmn9g29giqx6wmp-ntfy-sh-2.8.0/bin/ntfy serve -c /nix/store/ma711yry2gs6s8vsnrah1cy9fx0iipdv-server.yml (code=exited, status=238/STATE_DIRECTORY)
   Main PID: 8743 (code=exited, status=238/STATE_DIRECTORY)
         IP: 0B in, 0B out
        CPU: 882us

Mar 26 21:03:03 server systemd[1]: Started Push notifications server.
Mar 26 21:03:03 server (ntfy)[8743]: Directory "/var/lib/private" already exists, but has mode 0750 that is too permissive (0700 was requested), refusing.
Mar 26 21:03:03 server (ntfy)[8743]: ntfy-sh.service: Failed to set up special execution directory in /var/lib: File exists
Mar 26 21:03:03 server (ntfy)[8743]: ntfy-sh.service: Failed at step STATE_DIRECTORY spawning /nix/store/wgb20j6kkxz0j6d5ihmn9g29giqx6wmp-ntfy-sh-2.8.0/bin/ntfy: File exists
Mar 26 21:03:03 server systemd[1]: ntfy-sh.service: Main process exited, code=exited, status=238/STATE_DIRECTORY
Mar 26 21:03:03 server systemd[1]: ntfy-sh.service: Failed with result 'exit-code'.

Wrong User:

× ntfy-sh.service - Push notifications server
     Loaded: loaded (/etc/systemd/system/ntfy-sh.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Tue 2024-03-26 21:04:50 EET; 1s ago
   Duration: 3ms
    Process: 9917 ExecStart=/nix/store/wgb20j6kkxz0j6d5ihmn9g29giqx6wmp-ntfy-sh-2.8.0/bin/ntfy serve -c /nix/store/ma711yry2gs6s8vsnrah1cy9fx0iipdv-server.yml (code=exited, status=238/STATE_DIRECTORY)
   Main PID: 9917 (code=exited, status=238/STATE_DIRECTORY)
         IP: 0B in, 0B out
        CPU: 922us

Mar 26 21:04:50 server systemd[1]: Started Push notifications server.
Mar 26 21:04:50 server (ntfy)[9917]: Directory "/var/lib/private" already exists, but is owned by 989:986 (0:0 was requested), refusing.
Mar 26 21:04:50 server (ntfy)[9917]: ntfy-sh.service: Failed to set up special execution directory in /var/lib: File exists
Mar 26 21:04:50 server (ntfy)[9917]: ntfy-sh.service: Failed at step STATE_DIRECTORY spawning /nix/store/wgb20j6kkxz0j6d5ihmn9g29giqx6wmp-ntfy-sh-2.8.0/bin/ntfy: File exists
Mar 26 21:04:50 server systemd[1]: ntfy-sh.service: Main process exited, code=exited, status=238/STATE_DIRECTORY
Mar 26 21:04:50 server systemd[1]: ntfy-sh.service: Failed with result 'exit-code'.
binwiederhier commented 8 months ago

The Nix package is linked in the install instructions, but not officially maintained by us. See https://github.com/binwiederhier/ntfy/pull/462 - You may want to reach out to @wamserma