summary refs log tree commit diff
path: root/pkgs/common-updater
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2021-04-24 03:42:01 +0200
committerJan Tojnar <jtojnar@gmail.com>2021-04-24 03:42:01 +0200
commit38e20a3242a8dbd50d1c7d2dc060232edb7d907f (patch)
treeefffdb05f81a8c05953f305f0f8c97aed559f387 /pkgs/common-updater
parent3c781e6d191b716e0f693d6ee214f11a1ae4f832 (diff)
downloadnixpkgs-38e20a3242a8dbd50d1c7d2dc060232edb7d907f.tar
nixpkgs-38e20a3242a8dbd50d1c7d2dc060232edb7d907f.tar.gz
nixpkgs-38e20a3242a8dbd50d1c7d2dc060232edb7d907f.tar.bz2
nixpkgs-38e20a3242a8dbd50d1c7d2dc060232edb7d907f.tar.lz
nixpkgs-38e20a3242a8dbd50d1c7d2dc060232edb7d907f.tar.xz
nixpkgs-38e20a3242a8dbd50d1c7d2dc060232edb7d907f.tar.zst
nixpkgs-38e20a3242a8dbd50d1c7d2dc060232edb7d907f.zip
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.
Diffstat (limited to 'pkgs/common-updater')
-rwxr-xr-xpkgs/common-updater/scripts/update-source-version8
1 files changed, 8 insertions, 0 deletions
diff --git a/pkgs/common-updater/scripts/update-source-version b/pkgs/common-updater/scripts/update-source-version
index 0c914ebee2c..15792e1502e 100755
--- a/pkgs/common-updater/scripts/update-source-version
+++ b/pkgs/common-updater/scripts/update-source-version
@@ -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 '"')