Skip to content

Commit 151cf04

Browse files
committed
[nix] hack to make libgit2-sys builds more reliable
Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
1 parent 4c19b5a commit 151cf04

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

flake.nix

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,28 @@
152152
makeClauses = lib.strings.concatStringsSep "\n"
153153
(lib.mapAttrsToList makeClause deps);
154154
in ''
155-
manifest=$(''${base}/bin/cargo locate-project --message-format plain --workspace)
155+
base_cargo() {
156+
PATH="$base/bin:$PATH" "$base/bin/cargo" "$@"
157+
}
158+
159+
manifest=$(base_cargo locate-project --message-format plain --workspace)
156160
case "$manifest" in
157161
${matchClauses}
158162
esac
159163
if [ -f ''${root}/flake.nix ]; then
160164
sed -i '/# vendor dependency configuration generated by nix/{N;d;}' $root/.git/info/exclude
161165
${makeClauses}
162166
fi
167+
168+
# libgit2-sys copies a vendored git2 into the target/
169+
# directory somewhere. In certain, rare, cases,
170+
# libgit2-sys is rebuilt in the same incremental dep
171+
# directory as it was before, and then this copy fails,
172+
# because the files, copied from the nix store, already
173+
# exist and do not have w permission. Hack around this
174+
# issue by making any existing libgit2-sys vendored git2
175+
# files writable before a build can be run
176+
find "$(base_cargo metadata --format-version 1 | jq -r '.target_directory')" -path '*/build/libgit2-sys-*/out/include' -print0 | xargs -r -0 chmod u+w -R
163177
'';
164178

165179
# Hyperlight scripts use cargo in a bunch of ways that don't

0 commit comments

Comments
 (0)