From cc3f1c1de0ef241f4cae08afb614c8d891d0a847 Mon Sep 17 00:00:00 2001 From: Daniel Goertzen Date: Fri, 3 Jun 2022 16:36:19 -0500 Subject: [PATCH 1/2] force fetchGit allRefs when a dependency is specified with "rev" The usage of git "rev" dependencies in Cargo implies that the rev will be found regardless of ref. This is currently not true in naersk; the following dependency fails: usbfs = {git = "https://github.com/goertzenator/usbfs-rs", rev = "7c35b46e41ad76f838cd99b493f9337f475b5b70"} --- lib.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib.nix b/lib.nix index fa592c2..6dd306b 100644 --- a/lib.nix +++ b/lib.nix @@ -111,7 +111,7 @@ rec ref = lock.branch; } // lib.optionalAttrs (lock ? tag) { ref = lock.tag; - } // lib.optionalAttrs gitAllRefs { + } // lib.optionalAttrs (gitAllRefs || lock ? rev) { allRefs = true; } // lib.optionalAttrs gitSubmodules { submodules = true; From f6aa3915d003beb96cbcd2f00477ea1caa811cc8 Mon Sep 17 00:00:00 2001 From: Daniel Goertzen Date: Mon, 6 Jun 2022 09:31:15 -0500 Subject: [PATCH 2/2] remove fetchGit allRefs flag for nix <2.4 Prevent use of allRefs when nix <2.4 is in use. nix <2.4 does not accept the `allRefs` flag, but has `allRefs` behavior by default. Note that this goes beyond the the initial intent of this PR because it enables naersk's `gitAllRefs` flag to work on nix <2.4. --- lib.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib.nix b/lib.nix index 6dd306b..bd31e28 100644 --- a/lib.nix +++ b/lib.nix @@ -111,7 +111,7 @@ rec ref = lock.branch; } // lib.optionalAttrs (lock ? tag) { ref = lock.tag; - } // lib.optionalAttrs (gitAllRefs || lock ? rev) { + } // lib.optionalAttrs ((lib.versionAtLeast builtins.nixVersion "2.4") && (gitAllRefs || lock ? rev)) { allRefs = true; } // lib.optionalAttrs gitSubmodules { submodules = true;