From 0889dd50b02fc894078c382a9c43b5b46a3c6d03 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Thu, 12 Dec 2024 15:25:41 -0800 Subject: [PATCH] nix-prefetch-git: Fix on macOS Due to a CppNix bug which causes `nix-hash` to error on any file in a symlinked directory, `nix-prefetch-git` doesn't work on macOS [1], where `/tmp` and `/var` are both symlinks. Due to versions of CppNix older than 2.24 being removed from Nixpkgs despite known unfixed regressions [2], I can neither locate which version of CppNix introduced this bug or mitigate it by using an older version of CppNix. Therefore, I have replaced CppNix with Lix [3] in `nix-prefetch-git` (and the other `nix-prefetch-scripts`). Lix is based off of CppNix 2.18 and includes bugfixes backported from later versions of CppNix, so it does not suffer from this issue. Lix is compatible with CppNix 2.18, so this won't cause any regressions in behavior in the `nix-prefetch-scripts`. Before: ``` $ ./result/bin/nix-prefetch-git https://github.com/iand675/hs-sqlcommenter.git Initialized empty Git repository in /private/var/folders/z5/fclwwdms3r1gq4k4p3pkvvc00000gn/T/git-checkout-tmp-3WITGvxC/hs-sqlcommenter/.git/ remote: Enumerating objects: 16, done. remote: Counting objects: 100% (16/16), done. remote: Compressing objects: 100% (12/12), done. remote: Total 16 (delta 0), reused 16 (delta 0), pack-reused 0 (from 0) Unpacking objects: 100% (16/16), 14.14 KiB | 1.18 MiB/s, done. From https://github.com/iand675/hs-sqlcommenter * branch HEAD -> FETCH_HEAD Switched to a new branch 'fetchgit' removing `.git'... error: path '/var' is a symlink ``` After: ``` $ ./result/bin/nix-prefetch-git https://github.com/iand675/hs-sqlcommenter.git Initialized empty Git repository in /private/var/folders/z5/fclwwdms3r1gq4k4p3pkvvc00000gn/T/git-checkout-tmp-mvc00tOe/hs-sqlcommenter/.git/ remote: Enumerating objects: 16, done. remote: Counting objects: 100% (16/16), done. remote: Compressing objects: 100% (12/12), done. remote: Total 16 (delta 0), reused 16 (delta 0), pack-reused 0 (from 0) Unpacking objects: 100% (16/16), 14.14 KiB | 1.18 MiB/s, done. From https://github.com/iand675/hs-sqlcommenter * branch HEAD -> FETCH_HEAD Switched to a new branch 'fetchgit' removing `.git'... git revision is 7e946654a6fb08f25ebc75b90bb6bbc60c1392bf path is /nix/store/mkiv8ghgsyxf44ykk1n510yscvrhrgqi-hs-sqlcommenter git human-readable version is -- none -- Commit date is 2024-07-11 19:10:11 +0200 hash is 0ijxcp0x0xismp8q457bgvj65s43s4zakk64v7h74wyknhv87hgi { "url": "https://github.com/iand675/hs-sqlcommenter.git", "rev": "7e946654a6fb08f25ebc75b90bb6bbc60c1392bf", "date": "2024-07-11T19:10:11+02:00", "path": "/nix/store/mkiv8ghgsyxf44ykk1n510yscvrhrgqi-hs-sqlcommenter", "sha256": "0ijxcp0x0xismp8q457bgvj65s43s4zakk64v7h74wyknhv87hgi", "hash": "sha256-8cGDNrTTc3Lg2cTMqT7Rg+hi5H7rFILRrTp20MFlXUY=", "fetchLFS": false, "fetchSubmodules": false, "deepClone": false, "leaveDotGit": false } ``` [1]: https://github.com/NixOS/nix/issues/11756#issuecomment-2540202316 [2]: https://github.com/NixOS/nixpkgs/pull/359215#issuecomment-2515965863 [3]: https://lix.systems/ --- .../tools/package-management/nix-prefetch-scripts/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/tools/package-management/nix-prefetch-scripts/default.nix b/pkgs/tools/package-management/nix-prefetch-scripts/default.nix index 03694728a6e88..f065742094c35 100644 --- a/pkgs/tools/package-management/nix-prefetch-scripts/default.nix +++ b/pkgs/tools/package-management/nix-prefetch-scripts/default.nix @@ -1,5 +1,5 @@ { lib, stdenv, makeWrapper, buildEnv -, bash, breezy, coreutils, cvs, findutils, gawk, git, git-lfs, gnused, mercurial, nix, subversion +, bash, breezy, coreutils, cvs, findutils, gawk, git, git-lfs, gnused, mercurial, lix, subversion }: let mkPrefetchScript = tool: src: deps: @@ -15,7 +15,7 @@ let mkPrefetchScript = tool: src: deps: installPhase = '' install -vD ${src} $out/bin/$name; wrapProgram $out/bin/$name \ - --prefix PATH : ${lib.makeBinPath (deps ++ [ gnused nix ])} \ + --prefix PATH : ${lib.makeBinPath (deps ++ [ gnused lix ])} \ --set HOME /homeless-shelter '';