Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33071996
D6149.1768444228.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D6149.1768444228.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
Thu, Jan 15, 2:30 AM (2 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5935383
Default Alt Text
D6149.1768444228.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