[Solved] Add /var/run directory?

Some services need some place to store (temporary) files, e.g. WebDAV (on lighttpd) needs a lock-file. Usually, /var/run/ is used for these cases.

BUT: How can I tell NixOS to create a directory (with owner/group/permissions) under /var/run at each boot? Or should a different directory or a different way be used?

Ok, I’ve found out: The best way is probably to use systemd.tmpfiles:

systemd.tmpfiles.rules = [ "d /run/lighttpd 0750 lighttpd lighttpd -" ];

See also:

This PR might be relevant to you too: tree-wide: nixos: /var/run -> /run by bobvanderlinden · Pull Request #51918 · NixOS/nixpkgs · GitHub

1 Like