nix: quote path uses to avoid issues with spaces

This is most important on MacOS, but in general is a good idea.

Resolves:
https://github.com/status-im/status-mobile/issues/13715

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2022-07-25 22:38:41 +02:00
parent 46e5def13d
commit c27a74e378
No known key found for this signature in database
GPG Key ID: 09AA5403E54D9931
13 changed files with 21 additions and 21 deletions

View File

@ -21,9 +21,9 @@ echo "${1}" | go-maven-resolver >> nix/deps/gradle/deps.urls
sort -uo nix/deps/gradle/deps.urls nix/deps/gradle/deps.urls sort -uo nix/deps/gradle/deps.urls nix/deps/gradle/deps.urls
# Re-generate dependencies JSON. # Re-generate dependencies JSON.
${GIT_ROOT}/nix/deps/gradle/generate.sh gen_deps_json "${GIT_ROOT}/nix/deps/gradle/generate.sh" gen_deps_json
# Re-generate dependencies list. # Re-generate dependencies list.
${GIT_ROOT}/nix/deps/gradle/generate.sh gen_deps_list "${GIT_ROOT}/nix/deps/gradle/generate.sh" gen_deps_list
echo -e "${GRN}Successfully added:${RST} ${BLD}${1}${RST}" >&2 echo -e "${GRN}Successfully added:${RST} ${BLD}${1}${RST}" >&2

View File

@ -68,7 +68,7 @@ function gen_deps_json() {
echo "Regenerating Nix files..." echo "Regenerating Nix files..."
# Gradle needs to be run in 'android' subfolder # Gradle needs to be run in 'android' subfolder
cd $GIT_ROOT/android cd "${GIT_ROOT}/android"
# Stop gradle daemons to avoid locking # Stop gradle daemons to avoid locking
./gradlew --stop >/dev/null ./gradlew --stop >/dev/null

View File

@ -4,7 +4,7 @@ set -Eeu
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel) GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
# Gradle needs to be run in 'android' subfolder # Gradle needs to be run in 'android' subfolder
cd $GIT_ROOT/android cd "${GIT_ROOT}/android"
AWK_SCRIPT="${GIT_ROOT}/nix/deps/gradle/gradle_parser.awk" AWK_SCRIPT="${GIT_ROOT}/nix/deps/gradle/gradle_parser.awk"

View File

@ -4,7 +4,7 @@ set -Eeu
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel) GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
# Gradle needs to be run in 'android' subfolder # Gradle needs to be run in 'android' subfolder
cd $GIT_ROOT/android cd "${GIT_ROOT}/android"
# Print all our sub-projects # Print all our sub-projects
./gradlew projects --no-daemon --console plain 2>&1 \ ./gradlew projects --no-daemon --console plain 2>&1 \

View File

@ -55,7 +55,7 @@ nixOpts=(
) )
# Save derivation from being garbage collected # Save derivation from being garbage collected
${GIT_ROOT}/nix/scripts/gcroots.sh "${TARGET}" "${@}" "${GIT_ROOT}/nix/scripts/gcroots.sh" "${TARGET}" "${@}"
# Run the actual build # Run the actual build
echo -e "${GRN}Running:${RST} ${BLD}nix-build "${nixOpts[@]}" ${@}${RST}" echo -e "${GRN}Running:${RST} ${BLD}nix-build "${nixOpts[@]}" ${@}${RST}"

View File

@ -34,7 +34,7 @@ copyNodeModules() {
local dst="${2}" local dst="${2}"
# WARNING: The ../ is there to avoid a Nix builtins.path bug: # WARNING: The ../ is there to avoid a Nix builtins.path bug:
# https://github.com/NixOS/nix/issues/3593 # https://github.com/NixOS/nix/issues/3593
local tmp=$(mktemp -d -p "$(dirname ${dst})/../") local tmp=$(mktemp -d -p "$(dirname "${dst}")/../")
# We use a temporary directory to use mv as "atomic" change # We use a temporary directory to use mv as "atomic" change
trap "removeDir ${tmp}" ERR INT HUP trap "removeDir ${tmp}" ERR INT HUP
@ -54,8 +54,8 @@ copyNodeModules() {
findFilesNewerThan() { findFilesNewerThan() {
local sentinel="${1}" local sentinel="${1}"
local dir="${2}" local dir="${2}"
find ${dir} -type f -writable \ find "${dir}" -type f -writable \
-newer ${sentinel} \ -newer "${sentinel}" \
-not -ipath "*/*android/build/*" -prune \ -not -ipath "*/*android/build/*" -prune \
-not -ipath "*/xcuserdata/*" -prune \ -not -ipath "*/xcuserdata/*" -prune \
-not -ipath "*/unpacked_bin/clj-kondo" \ -not -ipath "*/unpacked_bin/clj-kondo" \
@ -76,7 +76,7 @@ nodeModulesUnchanged() {
fi fi
# Sentinel file holds location of the node_modules source in Nix store # Sentinel file holds location of the node_modules source in Nix store
currentNixSrc="$(cat ${sentinelFile})" currentNixSrc="$(cat "${sentinelFile}")"
if [ "${currentNixSrc}" != "${src}" ]; then if [ "${currentNixSrc}" != "${src}" ]; then
echo -e "${YLW}Yarn modules changed, copying new version over${RST}" >&2 echo -e "${YLW}Yarn modules changed, copying new version over${RST}" >&2
@ -89,7 +89,7 @@ nodeModulesUnchanged() {
echo -e "${YLW}Changes detected in node_modules:${RST} ${#modifiedFiles[@]}" >&2 echo -e "${YLW}Changes detected in node_modules:${RST} ${#modifiedFiles[@]}" >&2
# Print files that have changes # Print files that have changes
for file in ${modifiedFiles[@]}; do for file in ${modifiedFiles[@]}; do
echo "- $(realpath --relative-to=${dst} ${file})" >&2 echo "- $(realpath --relative-to="${dst}" "${file}")" >&2
done done
return 1 return 1
fi fi
@ -103,14 +103,14 @@ replaceNodeModules() {
local dst="$2" local dst="$2"
local sentinelFile="${dst}/.copied~" local sentinelFile="${dst}/.copied~"
if nodeModulesUnchanged ${src} ${dst}; then if nodeModulesUnchanged "${src}" "${dst}"; then
return return
fi fi
# Replace node_modules if necessary # Replace node_modules if necessary
echo "Copying node_modules from Nix store:" >&2 echo "Copying node_modules from Nix store:" >&2
echo " - ${src}" >&2 echo " - ${src}" >&2
copyNodeModules ${src} ${dst} copyNodeModules "${src}" "${dst}"
echo -n "${src}" > "${sentinelFile}" echo -n "${src}" > "${sentinelFile}"
} }
@ -130,4 +130,4 @@ export -f replaceNodeModules nodeModulesUnchanged copyNodeModules findFilesNewer
mkdir -p "${dst}" mkdir -p "${dst}"
# Leverage file lock to create an exclusive lock. # Leverage file lock to create an exclusive lock.
# Otherwise multiple calls to this script would clash. # Otherwise multiple calls to this script would clash.
flock "${dst}/" sh -c "time replaceNodeModules ${src} ${dst}" flock "${dst}/" sh -c "time replaceNodeModules '${src}' '${dst}'"

View File

@ -75,7 +75,7 @@ nix_purge_user_profile() {
~/.nix-* \ ~/.nix-* \
~/.cache/nix \ ~/.cache/nix \
~/.config/nixpkgs \ ~/.config/nixpkgs \
${GIT_ROOT}/.nix-gcroots "${GIT_ROOT}/.nix-gcroots"
} }
nix_purge_root() { nix_purge_root() {

View File

@ -67,7 +67,7 @@ fi
echo -e "${GRN}Configuring ${pureDesc}Nix shell for target '${TARGET}'...${RST}" 1>&2 echo -e "${GRN}Configuring ${pureDesc}Nix shell for target '${TARGET}'...${RST}" 1>&2
# Save derivation from being garbage collected # Save derivation from being garbage collected
${GIT_ROOT}/nix/scripts/gcroots.sh "shells.${TARGET}" "${GIT_ROOT}/nix/scripts/gcroots.sh" "shells.${TARGET}"
# ENTER_NIX_SHELL is the fake command used when `make shell` is run. # ENTER_NIX_SHELL is the fake command used when `make shell` is run.
# It is just a special string, not a variable, and a marker to not use `--run`. # It is just a special string, not a variable, and a marker to not use `--run`.

View File

@ -25,7 +25,7 @@ main() {
# Setup Nix if not available # Setup Nix if not available
if [[ ! -d /nix ]]; then if [[ ! -d /nix ]]; then
${GIT_ROOT}/nix/scripts/setup.sh "${GIT_ROOT}/nix/scripts/setup.sh"
fi fi
# Load Nix profile # Load Nix profile

View File

@ -16,7 +16,7 @@ let
node-sh = mkShell { node-sh = mkShell {
shellHook = '' shellHook = ''
export STATUS_MOBILE_HOME=$(git rev-parse --show-toplevel) export STATUS_MOBILE_HOME=$(git rev-parse --show-toplevel)
$STATUS_MOBILE_HOME/nix/scripts/node_modules.sh ${pkgs.deps.nodejs-patched} "$STATUS_MOBILE_HOME/nix/scripts/node_modules.sh" ${pkgs.deps.nodejs-patched}
''; '';
}; };

View File

@ -69,4 +69,4 @@ fi
nixOpts+=("--arg" "config" "{${config}}") nixOpts+=("--arg" "config" "{${config}}")
${GIT_ROOT}/nix/scripts/build.sh targets.mobile.android.release "${nixOpts[@]}" "${GIT_ROOT}/nix/scripts/build.sh" targets.mobile.android.release "${nixOpts[@]}"

View File

@ -10,7 +10,7 @@ function property() {
} }
function gradle_property() { function gradle_property() {
property ${GIT_ROOT}/android/gradle.properties ${1} property "${GIT_ROOT}/android/gradle.properties" ${1}
} }
function env_var_or_gradle_prop() { function env_var_or_gradle_prop() {

View File

@ -9,7 +9,7 @@ function property() {
} }
function gradle_property() { function gradle_property() {
property ${GIT_ROOT}/android/gradle.properties ${1} property "${GIT_ROOT}/android/gradle.properties" ${1}
} }
function env_var_or_gradle_prop() { function env_var_or_gradle_prop() {