nix-darwin icon indicating copy to clipboard operation
nix-darwin copied to clipboard

Setup a general writable folder for modules

Open shyim opened this issue 2 years ago • 4 comments

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? 😅

shyim avatar Apr 26 '22 12:04 shyim

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).

reckenrode avatar May 06 '22 01:05 reckenrode

when we create users we would have also a writeable folder 🤔

shyim avatar May 06 '22 06:05 shyim

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.

reckenrode avatar May 06 '22 20:05 reckenrode

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.

LnL7 avatar May 07 '22 10:05 LnL7