LnL7 / nix-darwin

nix modules for darwin
MIT License
2.82k stars 431 forks source link

`services.nix-daemon.environmentVariables` #993

Open lrworth opened 3 months ago

lrworth commented 3 months ago

https://github.com/LnL7/nix-darwin/commit/a9e0f71c50fc9a72e22e991e323a6a7e50bfc0d7 made it possible to modify the environment passed to nix-daemon. This turns out to also be useful for other things, so let's make it a little more idiomatic and document it.

emilazy commented 2 months ago

Thanks for the contribution! The current behaviour matches NixOS, so I’m a little worried about introducing divergence with their module. Maybe it’d be a good idea to get this upstream in NixOS too so we can minimize the differences and users can share their configuration? On the other hand I don’t want to double your work. Does setting launchd.daemons.nix-daemon.serviceConfig.EnvironmentVariables work currently? That at least signals that the same option won’t work on NixOS too.

lrworth commented 2 months ago

As far as I can tell, config.nix.envVars is not documented in NixOS either so perhaps upstreaming this change is a good idea; but I don't have a NixOS machine to test with, nor time to set one up.

Does setting launchd.daemons.nix-daemon.serviceConfig.EnvironmentVariables work currently?

I'm not sure what you are asking. That field is already used to configure the environment variables in /Library/LaunchDaemons/org.nixos.nix-daemon.plist.

emilazy commented 2 months ago

Totally understood re: NixOS. I’ll try to find the time to raise it there, but I suspect the answer would be “just use the systemd.* settings”, which is why I brought up launchd.*.

I'm not sure what you are asking. That field is already used to configure the environment variables in /Library/LaunchDaemons/org.nixos.nix-daemon.plist.

Ah, the difference is that nix.nixVars also gets added to your shell environment. I assumed that the idea of this option was for things that you wanted the daemon and your user to have separate values for, which is why I suggested setting them directly in the launchd.* options.