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
# 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.
${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

View File

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

View File

@ -4,7 +4,7 @@ set -Eeu
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
# 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"

View File

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

View File

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

View File

@ -34,7 +34,7 @@ copyNodeModules() {
local dst="${2}"
# WARNING: The ../ is there to avoid a Nix builtins.path bug:
# 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
trap "removeDir ${tmp}" ERR INT HUP
@ -54,8 +54,8 @@ copyNodeModules() {
findFilesNewerThan() {
local sentinel="${1}"
local dir="${2}"
find ${dir} -type f -writable \
-newer ${sentinel} \
find "${dir}" -type f -writable \
-newer "${sentinel}" \
-not -ipath "*/*android/build/*" -prune \
-not -ipath "*/xcuserdata/*" -prune \
-not -ipath "*/unpacked_bin/clj-kondo" \
@ -76,7 +76,7 @@ nodeModulesUnchanged() {
fi
# Sentinel file holds location of the node_modules source in Nix store
currentNixSrc="$(cat ${sentinelFile})"
currentNixSrc="$(cat "${sentinelFile}")"
if [ "${currentNixSrc}" != "${src}" ]; then
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
# Print files that have changes
for file in ${modifiedFiles[@]}; do
echo "- $(realpath --relative-to=${dst} ${file})" >&2
echo "- $(realpath --relative-to="${dst}" "${file}")" >&2
done
return 1
fi
@ -103,14 +103,14 @@ replaceNodeModules() {
local dst="$2"
local sentinelFile="${dst}/.copied~"
if nodeModulesUnchanged ${src} ${dst}; then
if nodeModulesUnchanged "${src}" "${dst}"; then
return
fi
# Replace node_modules if necessary
echo "Copying node_modules from Nix store:" >&2
echo " - ${src}" >&2
copyNodeModules ${src} ${dst}
copyNodeModules "${src}" "${dst}"
echo -n "${src}" > "${sentinelFile}"
}
@ -130,4 +130,4 @@ export -f replaceNodeModules nodeModulesUnchanged copyNodeModules findFilesNewer
mkdir -p "${dst}"
# Leverage file lock to create an exclusive lock.
# 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-* \
~/.cache/nix \
~/.config/nixpkgs \
${GIT_ROOT}/.nix-gcroots
"${GIT_ROOT}/.nix-gcroots"
}
nix_purge_root() {

View File

@ -67,7 +67,7 @@ fi
echo -e "${GRN}Configuring ${pureDesc}Nix shell for target '${TARGET}'...${RST}" 1>&2
# 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.
# 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
if [[ ! -d /nix ]]; then
${GIT_ROOT}/nix/scripts/setup.sh
"${GIT_ROOT}/nix/scripts/setup.sh"
fi
# Load Nix profile

View File

@ -16,7 +16,7 @@ let
node-sh = mkShell {
shellHook = ''
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}}")
${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() {
property ${GIT_ROOT}/android/gradle.properties ${1}
property "${GIT_ROOT}/android/gradle.properties" ${1}
}
function env_var_or_gradle_prop() {

View File

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