Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions pkgs/by-name/re/repath-studio/hardcode-git-paths.patch

This file was deleted.

61 changes: 39 additions & 22 deletions pkgs/by-name/re/repath-studio/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
pkg-config,
electron,
chromium,
cacert,
clojure,
git,
vips,

writeShellScriptBin,
copyDesktopItems,
makeDesktopItem,
makeWrapper,
replaceVars,

nixosTests,
}:
Expand All @@ -30,15 +31,7 @@ buildNpmPackage (finalAttrs: {
};

patches = [
(replaceVars ./hardcode-git-paths.patch {
clj-kdtree_src = fetchFromGitHub {
owner = "abscondment";
repo = "clj-kdtree";
rev = "5ec321c5e8006db00fa8b45a8ed9eb0b8f3dd56d";
hash = "sha256-ZOv+9TxBsOnSSbfM7kJLP3cQH9FpgA15aETszg7YSes=";
};
})
# outputHash of manvenDeps changes each time `clojure` is updated
# outputHash of clojureHome changes each time `clojure` is updated
# https://github.com/ngi-nix/ngipkgs/pull/1727#discussion_r2470180998
./pin-clojure.patch
];
Expand All @@ -48,7 +41,7 @@ buildNpmPackage (finalAttrs: {
npmDepsHash = "sha256-gOk/hHWGLwAxPIBqasoUzfszPv911afb/VLn7w7g5KE=";

nativeBuildInputs = [
finalAttrs.passthru.clojureWithCache
finalAttrs.passthru.clojureWithHome
makeWrapper
copyDesktopItems
pkg-config # sharp
Expand Down Expand Up @@ -138,48 +131,72 @@ buildNpmPackage (finalAttrs: {

passthru = {
# this was taken and adapted from "logseq" package's nixpkgs derivation
mavenRepo = stdenv.mkDerivation {
name = "repath-studio-${finalAttrs.version}-maven-deps";
clojureHome = stdenv.mkDerivation {
name = "repath-studio-${finalAttrs.version}-clojure-home";
inherit (finalAttrs) src patches;

nativeBuildInputs = [ clojure ];
nativeBuildInputs = [
cacert
clojure
git
];

buildPhase = ''
runHook preBuild

export HOME="$(mktemp -d)"
mkdir -p "$out"
export HOME="$out"
export JAVA_TOOL_OPTIONS="-Duser.home=$out"

# -P -> resolve all normal deps
# -M:alias -> resolve extra-deps of the listed aliases
clj -Sdeps "{:mvn/local-repo \"$out\"}" -P -M:dev:cljs
clojure -P -M:dev:cljs

runHook postBuild
'';

# copied from buildMavenPackage
# keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files with lastModified timestamps inside
installPhase = ''
runHook preInstall

find $out -type f \( \
# copied from buildMavenPackage
# keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files with lastModified timestamps inside
find "$out/.m2/repository" -type f \( \
-name \*.lastUpdated \
-o -name resolver-status.properties \
-o -name _remote.repositories \) \
-delete

# remove .git pointers to the bare repos in _repos
find "$out/.gitlibs/libs" -type f -name .git -delete

# keep only the bare repo config files so the clojure CLI doesn't want to fetch the repos again
# but make them be empty for reproducibility
find "$out/.gitlibs/_repos" -type f -name "config" -print0 | while read -d "" f; do
rm -rf "$(dirname "$f")"
mkdir "$(dirname "$f")"
touch "$f"
done

# recreate .clojure with empty settings
rm -r "$out/.clojure"
mkdir -p "$out/.clojure/tools"
echo "{}" > "$out/.clojure/deps.edn"
echo "{}" > "$out/.clojure/tools/tools.edn"

runHook postInstall
'';

dontFixup = true;

outputHash = "sha256-fwKeKfOIAWj9HQdXpEafZuJz5jwXNKpkS0JmuP3FXo0=";
outputHash = "sha256-wpE6MAWXxrDq3Y8a+rr9PhBz9Qnj23HB+a+eselUf4Y=";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After I rolled back hashes from the previous version and re-ran the update script, the pin-clojure.patch file became empty, thus changing this hash:

diff --git a/pkgs/by-name/re/repath-studio/package.nix b/pkgs/by-name/re/repath-studio/package.nix
index 015b4c217d19..f6f1eb3cb986 100644
--- a/pkgs/by-name/re/repath-studio/package.nix
+++ b/pkgs/by-name/re/repath-studio/package.nix
@@ -196,7 +196,7 @@ buildNpmPackage (finalAttrs: {
 
       dontFixup = true;
 
-      outputHash = "sha256-wpE6MAWXxrDq3Y8a+rr9PhBz9Qnj23HB+a+eselUf4Y=";
+      outputHash = "sha256-OT6z1tZPBoBG9iVsWTGiQYFljnIi2XQ1uqoQjn98ias=";
       outputHashMode = "recursive";
       outputHashAlgo = "sha256";
     };
diff --git a/pkgs/by-name/re/repath-studio/pin-clojure.patch b/pkgs/by-name/re/repath-studio/pin-clojure.patch
index a49fccbf0bf9..e69de29bb2d1 100644
--- a/pkgs/by-name/re/repath-studio/pin-clojure.patch
+++ b/pkgs/by-name/re/repath-studio/pin-clojure.patch
@@ -1,12 +0,0 @@
-diff --git a/deps.edn b/deps.edn
-index 158801e..91ea375 100644
---- a/deps.edn
-+++ b/deps.edn
-@@ -1,5 +1,6 @@
- {:paths ["src"]
-- :deps {binaryage/devtools {:mvn/version "1.0.7"}
-+ :deps {org.clojure/clojure {:mvn/version "1.12.4"}
-+        binaryage/devtools {:mvn/version "1.0.7"}
-         camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.3"}
-         clj-kdtree/clj-kdtree {:git/url "https://github.com/abscondment/clj-kdtree.git"
-                                :sha "5ec321c5e8006db00fa8b45a8ed9eb0b8f3dd56d"

outputHashMode = "recursive";
outputHashAlgo = "sha256";
};

clojureWithCache = writeShellScriptBin "clojure" ''
exec ${lib.getExe' clojure "clojure"} -Sdeps '{:mvn/local-repo "${finalAttrs.passthru.mavenRepo}"}' "$@"
clojureWithHome = writeShellScriptBin "clojure" ''
export HOME="${finalAttrs.passthru.clojureHome}"
export JAVA_TOOL_OPTIONS="-Duser.home=${finalAttrs.passthru.clojureHome}"
exec ${lib.getExe' clojure "clojure"} "$@"
'';

updateScript = ./update.sh;
Expand Down
42 changes: 7 additions & 35 deletions pkgs/by-name/re/repath-studio/update.sh

@eljamm eljamm May 28, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted the package hashes to the previous version:

repath-studio-0.4.13.patch

diff --git a/pkgs/by-name/re/repath-studio/package.nix b/pkgs/by-name/re/repath-studio/package.nix
index 015b4c217d19..667091ef643e 100644
--- a/pkgs/by-name/re/repath-studio/package.nix
+++ b/pkgs/by-name/re/repath-studio/package.nix
@@ -23,13 +23,13 @@
 }:
 buildNpmPackage (finalAttrs: {
   pname = "repath-studio";
-  version = "0.4.14";
+  version = "0.4.13";
 
   src = fetchFromGitHub {
     owner = "repath-studio";
     repo = "repath-studio";
     tag = "v${finalAttrs.version}";
-    hash = "sha256-El3gXpfNofHev84tpa0v16y2Sjdo6kmlm44hgHcinCk=";
+    hash = "sha256-YqBbhx5WDAElfNpPpSf1qXddK3kZhqGnHhXu/qVl1BA=";
   };
 
   patches = [
@@ -40,7 +40,7 @@ buildNpmPackage (finalAttrs: {
 
   makeCacheWritable = true;
 
-  npmDepsHash = "sha256-gOk/hHWGLwAxPIBqasoUzfszPv911afb/VLn7w7g5KE=";
+  npmDepsHash = "sha256-uTcHerTZwzeTFhjNs5ExgJU6u2fjDT5YlZemo3qNQOg=";
 
   nativeBuildInputs = [
     finalAttrs.passthru.clojureWithHome
@@ -196,7 +196,7 @@ buildNpmPackage (finalAttrs: {
 
       dontFixup = true;
 
-      outputHash = "sha256-wpE6MAWXxrDq3Y8a+rr9PhBz9Qnj23HB+a+eselUf4Y=";
+      outputHash = "sha256-rh9dcgk4qZkBDguUGFCE6ZcPnqBG/v4jlT8py1PUHYM=";
       outputHashMode = "recursive";
       outputHashAlgo = "sha256";
     };

and ran the update script, but it fails with:

repath-update.log

$ nix-update -u repath-studio
$ nix-instantiate --eval --json --strict /nix/store/04ld28pdbzy9x3ps5aaidlaf1d6bamxb-nix-update-1.15.0/lib/python3.13/site-packages/nix_update/eval.nix --argstr importPath /home/user/nixpkgs --argstr attribute '["repath-studio"]' --arg isFlake false --arg sanitizePositions true
$ nix-shell --extra-experimental-features 'flakes nix-command' /home/user/nixpkgs/maintainers/scripts/update.nix --argstr package repath-studio --argstr skip-prompt true
this derivation will be built:
  /nix/store/l1j56mj53x550k2si3w1f5pnfmrrlny9-packages.json.drv
building '/nix/store/l1j56mj53x550k2si3w1f5pnfmrrlny9-packages.json.drv'...

Going to be running update for following packages:
 - repath-studio-0.4.13


Running update for:
Enqueuing group of 1 packages
 - repath-studio-0.4.13: UPDATING ...
 - repath-studio-0.4.13: ERROR

--- SHOWING ERROR LOG FOR repath-studio-0.4.13 ----------------------

+ set -eou pipefail
+ token_args=
+ [[ -n '' ]]
++ curl -sL https://api.github.com/repos/repath-studio/repath-studio/releases/latest
++ jq -r .tag_name
+ latest_tag=v0.4.14
+ version=0.4.14
+ set +ue
+ [[ 0.4.13 == 0\.4\.14 ]]
+ set -ue
++ git rev-parse --show-toplevel
+ NIXPKGS_PATH=/home/user/nixpkgs
+++ dirname /home/user/nixpkgs/pkgs/by-name/re/repath-studio/update.sh
++ cd -- /home/user/nixpkgs/pkgs/by-name/re/repath-studio
++ pwd -P
+ PACKAGE_DIR=/home/user/nixpkgs/pkgs/by-name/re/repath-studio
+ PACKAGE_FILE=/home/user/nixpkgs/pkgs/by-name/re/repath-studio/package.nix
+ PATCH_CLJ_FILE=/home/user/nixpkgs/pkgs/by-name/re/repath-studio/pin-clojure.patch
+ pushd /home/user/nixpkgs
+ nix-update --version=0.4.14 repath-studio
+ popd
++ mktemp -d
+ TMPDIR=/tmp/nix-shell-3283903-3871424949/nix-shell-3284086-1268047038/nix-shell-3284272-3161139777/tmp.6svqZhmgak
+ trap 'rm -rf "$TMPDIR"' EXIT
+ pushd /tmp/nix-shell-3283903-3871424949/nix-shell-3284086-1268047038/nix-shell-3284272-3161139777/tmp.6svqZhmgak
++ nix-build --no-link /home/user/nixpkgs -A repath-studio.src
+ src=/nix/store/gfba7i658svv2kmkk828gx4w7pi7famd-source
+ cp /nix/store/gfba7i658svv2kmkk828gx4w7pi7famd-source/deps.edn deps.edn
+ workflow_file=/nix/store/gfba7i658svv2kmkk828gx4w7pi7famd-source/.github/workflows/desktop-app.yml
++ grep cli:
++ grep -A 10 'uses:.*setup-clojure' /nix/store/gfba7i658svv2kmkk828gx4w7pi7famd-source/.github/workflows/desktop-app.yml
++ head -n1
++ sed -E 's/.*cli:\s+([0-9]+\.[0-9]+\.[0-9]+).*/\1/'
+ clj_version=1.12.4
+ [[ -z 1.12.4 ]]
+ mkdir -p a b
+ cp deps.edn a/deps.edn
+ cp deps.edn b/deps.edn
+ sed -i '0,/:deps {/s|:deps {|:deps {org.clojure/clojure {:mvn/version "1.12.4"}\n        |' b/deps.edn
+ git diff --no-index --no-prefix a/deps.edn b/deps.edn
+ true
+ rm -rf a b
+ dummy_hash=sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
+ sed -i 's|outputHash = ".*";|outputHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";|' /home/user/nixpkgs/pkgs/by-name/re/repath-studio/package.nix
+ set +e
++ nix-build --no-link -A repath-studio.passthru.clojureHome /home/user/nixpkgs
++ grep got:
++ cut -d: -f2
++ sed 's| ||g'
+ new_clj_home_hash=
+ set -e
+ [[ -z '' ]]
+ echo 'Failed to get new clojure home hash.'
Failed to get new clojure home hash.
+ exit 1
+ rm -rf /tmp/nix-shell-3283903-3871424949/nix-shell-3284086-1268047038/nix-shell-3284272-3161139777/tmp.6svqZhmgak


--- SHOWING ERROR LOG FOR repath-studio-0.4.13 ----------------------
The update script for repath-studio-0.4.13 failed with exit code 1
Traceback (most recent call last):
  File "/nix/store/04ld28pdbzy9x3ps5aaidlaf1d6bamxb-nix-update-1.15.0/bin/.nix-update-wrapped", line 9, in <module>
    sys.exit(main())
             ~~~~^^
  File "/nix/store/04ld28pdbzy9x3ps5aaidlaf1d6bamxb-nix-update-1.15.0/lib/python3.13/site-packages/nix_update/__init__.py", line 475, in main
    package = update(options)
  File "/nix/store/04ld28pdbzy9x3ps5aaidlaf1d6bamxb-nix-update-1.15.0/lib/python3.13/site-packages/nix_update/update.py", line 198, in update
    run_update_script(package, opts)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/nix/store/04ld28pdbzy9x3ps5aaidlaf1d6bamxb-nix-update-1.15.0/lib/python3.13/site-packages/nix_update/update.py", line 138, in run_update_script
    run(
    ~~~^
        [
        ^
    ...<11 lines>...
        stdout=None,
        ^^^^^^^^^^^^
    )
    ^
  File "/nix/store/04ld28pdbzy9x3ps5aaidlaf1d6bamxb-nix-update-1.15.0/lib/python3.13/site-packages/nix_update/utils.py", line 54, in run
    return subprocess.run(
           ~~~~~~~~~~~~~~^
        command,
        ^^^^^^^^
    ...<5 lines>...
        env=env,
        ^^^^^^^^
    )
    ^
  File "/nix/store/0r6k8xa2kgqyp3r4v2w7yrb80ma2iawm-python3-3.13.12/lib/python3.13/subprocess.py", line 577, in run
    raise CalledProcessError(retcode, process.args,
                             output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['nix-shell', '--extra-experimental-features', 'flakes nix-command', '/home/user/nixpkgs/maintainers/scripts/update.nix', '--argstr', 'package', 'repath-studio', '--argstr', 'skip-prompt', 'true']' returned non-zero exit status 1.

pin-clojure.patch

b/deps.edn --- Clojure
Renamed from a/deps.edn to b/deps.edn
1    {:paths ["src"]
2     :deps {binaryage/devtools {:mvn/version "1.0.7"}
   2  :deps {org.clojure/clojure {:mvn/version "1.12.4"}
   4         camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.3"}
   5         clj-kdtree/clj-kdtree {:git/url "https://github.com/abscondment/clj-kdtree.git"
   6                                :sha "5ec321c5e8006db00fa8b45a8ed9eb0b8f3dd56d"
   7                                :deps/manifest :deps}

Edit: the issue was my git pager, producing an invalid patch. Could you please add --no-pager to the git diff command?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no such flag AFAICT.
Please send in the changes you think I should make as a change suggestion.

@eljamm eljamm May 28, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't suggest the change directly in GitHub since the line is not visible in the diff, but this is what I mean:

git --no-pager diff --no-index --no-prefix a/deps.edn b/deps.edn >"$PATCH_CLJ_FILE" || true

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ NIXPKGS_PATH="$(git rev-parse --show-toplevel)"
PACKAGE_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"

PACKAGE_FILE="$PACKAGE_DIR/package.nix"
PATCH_GIT_FILE="$PACKAGE_DIR/hardcode-git-paths.patch"
PATCH_CLJ_FILE="$PACKAGE_DIR/pin-clojure.patch"

pushd $NIXPKGS_PATH
Expand Down Expand Up @@ -58,55 +57,28 @@ cp deps.edn b/deps.edn

# insert clojure dep at start of :deps map
sed -i "0,/:deps {/s|:deps {|:deps {org.clojure/clojure {:mvn/version \"$clj_version\"}\n |" b/deps.edn
git diff --no-index --no-prefix a/deps.edn b/deps.edn >"$PATCH_CLJ_FILE" || true
git --no-pager diff --no-index --no-prefix a/deps.edn b/deps.edn >"$PATCH_CLJ_FILE" || true

rm -rf a b

# patches a dependency to be prefetched by nix
# clojure otherwise tries to fetch it at buildtime

# extract sha from clean deps.edn
clj_sha=$(grep -A 2 "clj-kdtree/clj-kdtree" deps.edn | grep -oP ':sha "\K[^"]+')

if [[ -z "$clj_sha" ]]; then
echo "Error: Could not extract clj-kdtree SHA from deps.edn" >&2
exit 1
fi

clj_hash=$(nix-prefetch-url --unpack "https://github.com/abscondment/clj-kdtree/archive/$clj_sha.tar.gz" --type sha256)
clj_hash=$(nix hash convert --hash-algo sha256 --from nix32 "$clj_hash")

sed -i "/owner = \"abscondment\"/,/hash =/ s/rev = \".*\"/rev = \"$clj_sha\"/" "$PACKAGE_FILE"
sed -i "/owner = \"abscondment\"/,/hash =/ s|hash = \".*\"|hash = \"$clj_hash\"|" "$PACKAGE_FILE"

mkdir -p a b
cp deps.edn a/deps.edn
cp deps.edn b/deps.edn

sed -i '/clj-kdtree\/clj-kdtree/,/:sha/c\ clj-kdtree/clj-kdtree {:local/root "@clj-kdtree_src@"' b/deps.edn
git diff --no-index --no-prefix a/deps.edn b/deps.edn >"$PATCH_GIT_FILE" || true

rm -rf a b
popd

# maven deps
# clojure home

dummy_hash="sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
sed -i "s|outputHash = \".*\";|outputHash = \"$dummy_hash\";|" "$PACKAGE_FILE"

# expect failure to get new hash
set +e
new_mvn_hash="$(
nix-build --no-link -A repath-studio.passthru.mavenRepo "$NIXPKGS_PATH" 2>&1 >/dev/null |
new_clj_home_hash="$(
nix-build --no-link -A repath-studio.passthru.clojureHome "$NIXPKGS_PATH" 2>&1 >/dev/null |
grep "got:" | cut -d':' -f2 | sed 's| ||g'
)"
set -e

if [[ -z "$new_mvn_hash" ]]; then
echo "Failed to get new maven hash." >&2
if [[ -z "$new_clj_home_hash" ]]; then
echo "Failed to get new clojure home hash." >&2
exit 1
fi

sed -i "s|\"$dummy_hash\"|\"$new_mvn_hash\"|g" "$PACKAGE_FILE"
sed -i "s|\"$dummy_hash\"|\"$new_clj_home_hash\"|g" "$PACKAGE_FILE"

echo "Update to $version complete."
Loading