NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.64k stars 13.8k forks source link

services.uptime-kuma.settings.DATA_DIR is not defined as default value #324105

Open BloodStainedCrow opened 3 months ago

BloodStainedCrow commented 3 months ago

Describe the bug

Setting a value for DATA_DIR results in The option 'services.uptime-kuma.settings.DATA_DIR' has conflicting definition values

Steps To Reproduce

Steps to reproduce the behavior:

  1. Add services.uptime-kuma = { enable = true; settings = { DATA_DIR = "/mnt/tank/uptime-kuma/data"; }; }; to your configuration.nix

Expected behavior

The default value of /var/lib/uptime-kuma/ gets overwritten by /mnt/tank/uptime-kuma/data

Screenshots

image

Additional context

This is a result of the defualt value for DATA_DIR not being labeled as mkDefault in it's definition

Notify maintainers

@JulienMalka

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.84, NixOS, 24.05 (Uakari), 24.05.20240701.d032c1a`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.4`
 - channels(root): `"nixos-24.05"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos

Add a :+1: reaction to issues you find important.

BloodStainedCrow commented 3 months ago

After trying unsuccessfully to get a modified DATA_DIR to work, I have concluded that if changed uptime-kuma will fail to start. I am not sure why exactly this happens. If the authors of the package could help explain why, I would be very grateful!

Guanran928 commented 3 months ago

Our Uptime Kuma's systemd service is hardened. https://github.com/NixOS/nixpkgs/blob/febd932858cfbc93d920a2ed6b9d852e93d3ad00/nixos/modules/services/monitoring/uptime-kuma.nix#L51-L72 ProtectSystem=strict means the entire file system hierarchy is mounted read-only, StateDirectory=uptime-kuma is used to make /var/lib/uptime-kuma writable.

For more info, see man 5 systemd.exec. Also, ReadWritePaths and SupplementaryGroups (I think it still works with DynamicUser=true) might be useful.