Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure environment PATH variable #1080

Open
niklasravnsborg opened this issue Sep 17, 2024 · 2 comments
Open

Configure environment PATH variable #1080

niklasravnsborg opened this issue Sep 17, 2024 · 2 comments

Comments

@niklasravnsborg
Copy link
Contributor

I'm looking for a way to declaratively set the PATH environment variable used by my macOS applications. I think currently there is no option for this in nix-darwin.

Setting the PATH variable is helpful when GUI apps should use binaries of the nix-store which they can't find by default, because the default PATH variable only includes /usr/bin:/bin:/usr/sbin:/sbin.

For some context refer to this Stackoverflow answer: https://stackoverflow.com/a/70510488.

@antoineco
Copy link
Contributor

antoineco commented Sep 17, 2024

It may not seem pretty, but since this is how the system module works under the hood, you may as well add your imperative command to one of the options below. It will be executed upon each activation.

system.activationScripts.extraUserActivation.text = mkDefault "";
system.activationScripts.preUserActivation.text = mkDefault "";
system.activationScripts.postUserActivation.text = mkDefault "";

Example:

    system.extraUserActivation.text = ''
      echo "setting user's persistent configuration information for launchd domains..."
      launchctl config user path /opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin
    '';

@niklasravnsborg
Copy link
Contributor Author

Running sudo launchctl config user path "/Users/nik/.nix-profile/bin:/usr/bin:/bin" gives me a 'sudo launchctl config user path…' terminated by signal SIGBUS (Misaligned address error). But I guess this is not a nix problem...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants