From 563522a2f5c16265f06e7dd98f4c93dbc46ac41b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Vask=C3=B3?= Date: Wed, 20 Oct 2021 18:33:06 +0200 Subject: [PATCH 1/2] fetchGit: work-around bug in Nix 2.4 Another approach to make `poetry2nix` work with dependencies specified by arbitrary `rev=` values on newer Nix revisions. Relates-to: https://github.com/nix-community/poetry2nix/pull/358 Relates-to: https://github.com/NixOS/nix/issues/5128 --- mk-poetry-dep.nix | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mk-poetry-dep.nix b/mk-poetry-dep.nix index 867f6d985..b45a82a03 100644 --- a/mk-poetry-dep.nix +++ b/mk-poetry-dep.nix @@ -163,11 +163,18 @@ pythonPackages.callPackage src = if isGit then ( - builtins.fetchGit { + builtins.fetchGit ({ inherit (source) url; rev = source.resolved_reference or source.reference; ref = sourceSpec.branch or sourceSpec.rev or (if sourceSpec?tag then "refs/tags/${sourceSpec.tag}" else "HEAD"); - } + } // ( + let + nixVersion = builtins.substring 0 3 builtins.nixVersion; + in + lib.optionalAttrs (lib.versionAtLeast nixVersion "2.4") { + allRefs = true; + } + )) ) else if isUrl then builtins.fetchTarball From fc4cdde60771e66aafd84805fdd74613f0b9b335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Vask=C3=B3?= Date: Thu, 21 Oct 2021 10:12:35 +0200 Subject: [PATCH 2/2] fetchGit: use `allRefs` only when it is needed If `branch` or `tag` is given in sourceSpec, then `fetchGit` would work as before, the only problematic setup is `rev` when used with Nix 2.4+ --- mk-poetry-dep.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mk-poetry-dep.nix b/mk-poetry-dep.nix index b45a82a03..c4cf610b7 100644 --- a/mk-poetry-dep.nix +++ b/mk-poetry-dep.nix @@ -166,12 +166,12 @@ pythonPackages.callPackage builtins.fetchGit ({ inherit (source) url; rev = source.resolved_reference or source.reference; - ref = sourceSpec.branch or sourceSpec.rev or (if sourceSpec?tag then "refs/tags/${sourceSpec.tag}" else "HEAD"); + ref = sourceSpec.branch or (if sourceSpec ? tag then "refs/tags/${sourceSpec.tag}" else "HEAD"); } // ( let nixVersion = builtins.substring 0 3 builtins.nixVersion; in - lib.optionalAttrs (lib.versionAtLeast nixVersion "2.4") { + lib.optionalAttrs ((sourceSpec ? rev) && (lib.versionAtLeast nixVersion "2.4")) { allRefs = true; } ))