+1
doc/hooks/index.xml
+1
doc/hooks/index.xml
···
+50
doc/hooks/patch-rc-path-hooks.section.md
+50
doc/hooks/patch-rc-path-hooks.section.md
···+These hooks provide shell-specific utilities (with the same name as the hook) to patch shell scripts meant to be sourced by software users.+The typical usage is to patch initialisation or [rc](https://unix.stackexchange.com/questions/3467/what-does-rc-in-bashrc-stand-for) scripts inside `$out/bin` or `$out/etc`.+Such scripts, when being sourced, would insert the binary locations of certain commands into `PATH`, modify other environment variables or run a series of start-up commands.+When shipped from the upstream, they sometimes use commands that might not be available in the environment they are getting sourced in.+- `patchRcPathBash`: [Bash](https://www.gnu.org/software/bash/), [ksh](http://www.kornshell.org/), [zsh](https://www.zsh.org/) and other shells supporting the Bash-like parameter expansions.+- `patchRcPathPosix`: POSIX-conformant shells supporting the limited parameter expansions specified by the POSIX standard. Current implementation uses the parameter expansion `${foo-}` only.+For each supported shell, it modifies the script with a `PATH` prefix that is later removed when the script ends.+It allows nested patching, which guarantees that a patched script may source another patched script.+Given a package `foo` containing an init script `this-foo.fish` that depends on `coreutils`, `man` and `which`,+patch the init script for users to source without having the above dependencies in their `PATH`:+`patchRcPathCsh` and `patchRcPathPosix` implementation depends on `sed` to do the string processing.
+64
pkgs/build-support/setup-hooks/patch-rc-path-hooks/default.nix
+64
pkgs/build-support/setup-hooks/patch-rc-path-hooks/default.nix
···
+50
pkgs/build-support/setup-hooks/patch-rc-path-hooks/patch-rc-path-bash.sh
+50
pkgs/build-support/setup-hooks/patch-rc-path-hooks/patch-rc-path-bash.sh
···
+57
pkgs/build-support/setup-hooks/patch-rc-path-hooks/patch-rc-path-csh.sh
+57
pkgs/build-support/setup-hooks/patch-rc-path-hooks/patch-rc-path-csh.sh
···+setenv PATH \`echo "\$PATH" | @sed@ "s#\${NIXPKGS_SOURCETIME_PATH}##" | @sed@ "s#::#:#g" | @sed@ "s#^:##" | @sed@ 's#:\$##'\`
+50
pkgs/build-support/setup-hooks/patch-rc-path-hooks/patch-rc-path-fish.sh
+50
pkgs/build-support/setup-hooks/patch-rc-path-hooks/patch-rc-path-fish.sh
···+set --unpath NIXPKGS_SOURCETIME_PATH_OLD "\$NIXPKGS_SOURCETIME_PATH" \$NIXPKGS_SOURCETIME_PATH_OLD+if set -q PATH && test "\$PATH" != "" && test (count \$PATH) -ge (count \$NIXPKGS_SOURCETIME_PATH)
+39
pkgs/build-support/setup-hooks/patch-rc-path-hooks/patch-rc-path-posix.sh
+39
pkgs/build-support/setup-hooks/patch-rc-path-hooks/patch-rc-path-posix.sh
···+PATH="\$(echo "\$PATH" | @sed@ "s#\$NIXPKGS_SOURCETIME_PATH##" | @sed@ "s#::#:#g" | @sed@ "s#^:##" | @sed@ "s#:\\\$##")"+NIXPKGS_SOURCETIME_PATH="\$(echo "\$NIXPKGS_SOURCETIME_PATH_OLD" | @sed@ "s#\\([^;]\\);.*#\\1#")"+NIXPKGS_SOURCETIME_PATH_OLD="\$(echo "\$NIXPKGS_SOURCETIME_PATH_OLD" | @sed@ "s#[^;];\\(.*\\)#\\1#")"
+442
pkgs/build-support/setup-hooks/patch-rc-path-hooks/test/default.nix
+442
pkgs/build-support/setup-hooks/patch-rc-path-hooks/test/default.nix
···+echo "Testing in Bash if sample_source.bash and sample_source_patched.bash modifies PATH the same way"+echo "Testing in Ksh if sample_source.bash and sample_source_patched.bash modifies PATH the same way"+echo "Testing in Zsh if sample_source.bash and sample_source_patched.bash modifies PATH the same way"+echo "Testing in Bash if sample_source.bash and sample_source_patched.bash modifies PATH the same way"+echo "Testing in Ksh if sample_source.bash and sample_source_patched.bash modifies PATH the same way"+echo "Testing in Zsh if sample_source.bash and sample_source_patched.bash modifies PATH the same way"+echo "Testing in Csh if sample_source.csh and sample_source_patched.csh modifies PATH the same way"+echo "Testing in Csh if sample_source.csh and sample_source_patched.csh modifies PATH the same way"+echo "Testing in Fish if sample_source.fish and sample_source_patched.fish modifies PATH the same way"+HOME="$HOME_TEMP" fish ${./test-sourcing-fish} ${./sample_source.fish} sample_source_patched.fish+echo "Testing in Fish if sample_source.fish and sample_source_patched.fish modifies PATH the same way"+HOME="$HOME_TEMP" fish ${./test-sourcing-fish} ${./sample_source.fish} sample_source_patched.fish+echo "Testing in Bash if sample_source.bash and sample_source_patched.bash modifies PATH the same way"+echo "Testing in Dash if sample_source.sh and sample_source_patched.sh modifies PATH the same way"+echo "Testing in Ksh if sample_source.sh and sample_source_patched.sh modifies PATH the same way"+echo "Testing in Bash if sample_source.bash and sample_source_patched.bash modifies PATH the same way"+echo "Testing in Dash if sample_source.sh and sample_source_patched.sh modifies PATH the same way"+echo "Testing in Ksh if sample_source.sh and sample_source_patched.sh modifies PATH the same way"
+2
pkgs/build-support/setup-hooks/patch-rc-path-hooks/test/sample_source.bash
+2
pkgs/build-support/setup-hooks/patch-rc-path-hooks/test/sample_source.bash
+1
pkgs/build-support/setup-hooks/patch-rc-path-hooks/test/sample_source.csh.in
+1
pkgs/build-support/setup-hooks/patch-rc-path-hooks/test/sample_source.csh.in
···
+9
pkgs/build-support/setup-hooks/patch-rc-path-hooks/test/sample_source.fish
+9
pkgs/build-support/setup-hooks/patch-rc-path-hooks/test/sample_source.fish
+2
pkgs/build-support/setup-hooks/patch-rc-path-hooks/test/sample_source.sh.in
+2
pkgs/build-support/setup-hooks/patch-rc-path-hooks/test/sample_source.sh.in
+21
pkgs/build-support/setup-hooks/patch-rc-path-hooks/test/test-sourcing-bash
+21
pkgs/build-support/setup-hooks/patch-rc-path-hooks/test/test-sourcing-bash
···+echo "Result path mismatched: $UNPATCHED_SOURCE_FILE ($RESULT_PATH_FROM_UNPATCHED) and $PATCHED_SOURCE_FILE ($RESULT_PATH_FROM_PATCHED)" >&2
+13
pkgs/build-support/setup-hooks/patch-rc-path-hooks/test/test-sourcing-csh
+13
pkgs/build-support/setup-hooks/patch-rc-path-hooks/test/test-sourcing-csh
···+set RESULT_PATH_FROM_UNPATCHED = `setenv PATH "$ORIG_PATH"; source $UNPATCHED_SOURCE_FILE; echo $PATH`+set RESULT_PATH_FROM_PATCHED = `setenv PATH "$ORIG_PATH"; source $PATCHED_SOURCE_FILE; echo $PATH`+echo "Result path mismatched: $UNPATCHED_SOURCE_FILE ($RESULT_PATH_FROM_UNPATCHED) and $PATCHED_SOURCE_FILE ($RESULT_PATH_FROM_PATCHED)" > /dev/stderr
+13
pkgs/build-support/setup-hooks/patch-rc-path-hooks/test/test-sourcing-fish
+13
pkgs/build-support/setup-hooks/patch-rc-path-hooks/test/test-sourcing-fish
···+set RESULT_PATH_FROM_UNPATCHED (fish -c "set -g PATH \"$ORIG_PATH\"; source $UNPATCHED_SOURCE_FILE; echo \"\$PATH\"")+set RESULT_PATH_FROM_PATCHED (fish -c "set -g PATH \"$ORIG_PATH\"; source $PATCHED_SOURCE_FILE; echo \"\$PATH\"")+echo "Result path mismatched: $UNPATCHED_SOURCE_FILE ($RESULT_PATH_FROM_UNPATCHED) and $PATCHED_SOURCE_FILE ($RESULT_PATH_FROM_PATCHED)" >&2
+21
pkgs/build-support/setup-hooks/patch-rc-path-hooks/test/test-sourcing-posix
+21
pkgs/build-support/setup-hooks/patch-rc-path-hooks/test/test-sourcing-posix
···+echo "Result path mismatched: $UNPATCHED_SOURCE_FILE ($RESULT_PATH_FROM_UNPATCHED) and $PATCHED_SOURCE_FILE ($RESULT_PATH_FROM_PATCHED)" > /dev/stderr
+4
pkgs/top-level/all-packages.nix
+4
pkgs/top-level/all-packages.nix
···starboard-octant-plugin = callPackage ../applications/networking/cluster/octant/plugins/starboard-octant-plugin.nix { };