mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-01-11 14:20:23 +01:00
nix package installed by nix-darwin ignore the PATH env passed by the parent process
#16
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ryan4yin on GitHub (Dec 7, 2023).
Test Result on macOS with nix-darwin:
@ryan4yin commented on GitHub (Dec 7, 2023):
Tried to make a shell wrapper with the expected
PATH, but useless:087d38487c (diff-96e580d4ef2e5de2c220100b5b9352d1c3da3ebeecc623736db9cb953798642aR158-R174)@ryan4yin commented on GitHub (Dec 7, 2023):
Bash
Several config files used by Bash:
/etc/profile: A global configuration file that applies to all users. This file is read for login shells.~/.bash_profileor~/.profile: A personal initialization file for login shells. This is read after /etc/profile.~/.bashrc: A personal initialization file for non-login shells. This is specific to each user and allows them to customize their shell environment./etc/bash.bashrc: A system-wide initialization file for non-login shells. This is a feature specific to Debian and Ubuntu-like systems./etc/bashrcas its system-wide initialization file: https://github.com/NixOS/nixpkgs/blob/nixos-23.11/pkgs/shells/bash/5.nix#L44The problem we have here is related to non-login shell, and we have deleted
~/.bashrcbeafore we execute the test.So
/etc/bash.bashrcand/etc/bashrcmay be the root cause of this problem./etc/bash.bashrc(used by macOS's builtin bash):/etc/bashrc(used by nix-darwin's bash):set-environmentseems like a key word related to this issue, take a look at it:/nix/store/icwhz17wr4wgwp89n95mrs1ngj859c6m-set-environment:Oh set
__NIX_DARWIN_SET_ENVIRONMENT_DONEto1may prevent bash clear myPATH! let's test it!Succeeded!
So the root cause is the environemnt variable
__NIX_DARWIN_SET_ENVIRONMENT_DONEis missing, it should be1!@ryan4yin commented on GitHub (Dec 7, 2023):
Zsh
It has the same problem as bash:
/etc/zshenv:@ryan4yin commented on GitHub (Dec 7, 2023):
My default shell used in terminal is
nushell, but nix-darwin do not support to setnushellas a login shell.nix-darwin has option programs.zsh.loginShellInit but do not have a
programs.nushell.loginShellInit, which caused this problem!