common-updater-scripts: Replace flake source by local path

When update-source-version is run in a repo with flake-compat,
it would find the files in Nix store.

Let’s replace them with the local path of the repository.
This commit is contained in:
Jan Tojnar 2021-04-24 03:42:01 +02:00
parent 3c781e6d19
commit 38e20a3242
No known key found for this signature in database
GPG key ID: 7FAB2A15F7A607A4

View file

@ -83,6 +83,14 @@ if [[ -z "$nixFile" ]]; then
if [[ ! -f "$nixFile" ]]; then
die "Couldn't evaluate '$attr.meta.position' to locate the .nix file!"
fi
# flake-compat will return paths in the Nix store, we need to correct for that.
possiblyOutPath=$(nix-instantiate $systemArg --eval -E "with $importTree; outPath" | tr -d '"')
if [[ -n "$possiblyOutPath" ]]; then
outPathEscaped=$(echo "$possiblyOutPath" | sed 's#[$^*\\.[|]#\\&#g')
pwdEscaped=$(echo "$PWD" | sed 's#[$^*\\.[|]#\\&#g')
nixFile=$(echo "$nixFile" | sed "s|^$outPathEscaped|$pwdEscaped|")
fi
fi
oldHashAlgo=$(nix-instantiate $systemArg --eval --strict -A "$attr.src.drvAttrs.outputHashAlgo" | tr -d '"')