Something went wrong. Try again.
What happens if I push all of nixpkgs
Something went wrong. Try again.
1.8 kB · 50 lines
Shell
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051patchRcPathBash(){ local FILE_TO_PATCH="$1" local SOURCETIME_PATH="$2" local FILE_TO_WORK_ON="$(mktemp "$(basename "$FILE_TO_PATCH").XXXXXX.tmp")" cat <<EOF >> "$FILE_TO_WORK_ON"# Lines to add to PATH the source-time utilities for Nixpkgs packagingif [[ -n "\${NIXPKGS_SOURCETIME_PATH-}" ]]; then NIXPKGS_SOURCETIME_PATH_OLD="\$NIXPKGS_SOURCETIME_PATH;\${NIXPKGS_SOURCETIME_PATH_OLD-}"fiNIXPKGS_SOURCETIME_PATH="$SOURCETIME_PATH"if [[ -n "\$PATH" ]]; then PATH="\$NIXPKGS_SOURCETIME_PATH:\$PATH"else PATH="\$NIXPKGS_SOURCETIME_PATH"fiexport PATH# End of lines to add to PATH source-time utilities for Nixpkgs packagingEOF cat "$FILE_TO_PATCH" >> "$FILE_TO_WORK_ON" cat <<EOF >> "$FILE_TO_WORK_ON"# Lines to clean up inside PATH the source-time utilities for Nixpkgs packagingif [[ -n "\${PATH-}" ]]; then # Remove the inserted section PATH="\${PATH/\$NIXPKGS_SOURCETIME_PATH}" # Remove the duplicated colons PATH="\${PATH//::/:}" # Remove the prefixing colon if [[ -n "\$PATH" && "\${PATH:0:1}" == ":" ]]; then PATH="\${PATH:1}" fi # Remove the trailing colon if [[ -n "\$PATH" && "\${PATH:\${#PATH}-1}" == ":" ]]; then PATH="\${PATH::}" fi export PATHfiif [[ -n "\${NIXPKGS_SOURCETIME_PATH_OLD-}" ]]; then IFS="" read -r -d ";" NIXPKGS_SOURCETIME_PATH <<< "\$NIXPKGS_SOURCETIME_PATH_OLD" NIXPKGS_SOURCETIME_PATH_OLD="\${NIXPKGS_SOURCETIME_PATH_OLD:\${#NIXPKGS_SOURCETIME_PATH}+1}"else unset NIXPKGS_SOURCETIME_PATHfiif [[ -z "\${NIXPKGS_SOURCETIME_PATH_OLD-}" ]]; then unset NIXPKGS_SOURCETIME_PATH_OLDfi# End of lines to clean up inside PATH the source-time utilities for Nixpkgs packagingEOF cat "$FILE_TO_WORK_ON" > "$FILE_TO_PATCH" rm "$FILE_TO_WORK_ON"}