nix-darwin
nix-darwin copied to clipboard
Setup a general writable folder for modules
When writing a module it would be nice to have a place where all services writes their data to. Currently, the Redis service has an issue as by default the user cannot write to /var/lib/redis (https://github.com/LnL7/nix-darwin/blob/master/modules/services/redis/default.nix#L26) or in postgres /var/lib/postgres (https://github.com/LnL7/nix-darwin/blob/master/modules/services/postgresql/default.nix#L59)
I guess a generic folder like in homebrew /opt/homebrew
writeable by the user can solve this issue. I am the only one with this issue? 😅
Setting dataDir
in the module configuration to a path writeable by your user should work. Ideally, these would be more like the NixOS modules, which set up system services and create users specific to each (redis, postgres).
when we create users we would have also a writeable folder 🤔
It will if you specify createHome
. I tried setting this up to test, and it was pretty messy. I had to copy the launch agent to /Library/LaunchDaemons
and run it using sudo
so it could switch to the redis
user. That ended up being a lot less user-friendly than I expected. 😕
Instead of a shared folder all modules could use (because that seems risky), something like systemd.tmpfiles.rules
from NixOS would be nice. You could set it up to create a directory for your service and have it set the owner and permissions to whatever you wanted.
Yeah, there's currently no functionality to setup files/directories for services. Logfiles have a similar problem where launchd will completely refuse to start the service, so you have to either setup /var/log
yourself or use a shared folder like /tmp
which isn't really the proper place.