Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F2910195
D6149.id20738.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D6149.id20738.diff
View Options
diff --git a/scripts/install_nix.sh b/scripts/install_nix.sh
--- a/scripts/install_nix.sh
+++ b/scripts/install_nix.sh
@@ -12,6 +12,28 @@
fi
fi
+write_nix_path_to_file() {
+ target_file="$1"
+
+ # Only write to files if they are missing the entry and writeable
+ if ! grep nix-profile "$target_file" 2>/dev/null \
+ && [ -w "$target_file" ] || [ ! -f "$target_file" ]; then
+ echo "Adding Nix path entry to $target_file" >&2
+ # We want this to output $PATH without expansion
+ # shellcheck disable=SC2016
+ echo 'export PATH="$HOME"/.nix-profile/bin:/nix/var/nix/profiles/default/bin:"${PATH}"' >> "$target_file"
+ fi
+}
+
+# Apple may reset /etc/*rc on system updates which is how Nix exposes itself
+# Add user entries to avoid Nix "disappearing" from PATH
+if [[ "$OSTYPE" == 'darwin'* ]]; then
+ write_nix_path_to_file "$HOME/.zshenv"
+ write_nix_path_to_file "$HOME/.bashrc"
+ write_nix_path_to_file "$HOME/.bash_profile"
+ write_nix_path_to_file "$HOME/.profile"
+fi
+
# Figure out how many cores the system has, and set cache default
if [[ "$OSTYPE" == 'darwin'* ]]; then
NPROC=$(sysctl -n hw.physicalcpu)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Oct 7, 8:24 PM (22 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2255737
Default Alt Text
D6149.id20738.diff (1 KB)
Attached To
Mode
D6149: [Nix] Write Nix path to user shell files upon install
Attached
Detach File
Event Timeline
Log In to Comment