From ef1e2ef8c29cb0e8bca6382b3a348167d8132a2d Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Sat, 9 Mar 2024 00:01:11 +0800 Subject: [PATCH] fetchFromGitHub: take passthru and enhance overriding Take optional argument `passthru` for custom passthru attribute set. Update the `meta` attribute via `.overrideAttrs` instead of attribute set update (`//`). Attach attributes `owner`, `repo` and `rev` via `passthru` instead of attribute set update. --- pkgs/build-support/fetchgithub/default.nix | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/fetchgithub/default.nix b/pkgs/build-support/fetchgithub/default.nix index ad4d97b..039683e 100644 --- a/pkgs/build-support/fetchgithub/default.nix +++ b/pkgs/build-support/fetchgithub/default.nix @@ -8,6 +8,7 @@ lib.makeOverridable ( , deepClone ? false, private ? false, forceFetchGit ? false , sparseCheckout ? [] , githubBase ? "github.com", varPrefix ? null +, passthru ? { } , meta ? { } , ... # For hash agility }@args: @@ -21,6 +22,9 @@ let else builtins.unsafeGetAttrPos "rev" args ); baseUrl = "https://${githubBase}/${owner}/${repo}"; + newPassthru = passthru // { + inherit rev owner repo; + }; newMeta = meta // { homepage = meta.homepage or baseUrl; } // lib.optionalAttrs (position != null) { @@ -57,16 +61,19 @@ let fetcherArgs = (if useFetchGit then { inherit rev deepClone fetchSubmodules sparseCheckout; url = gitRepoUrl; + passthru = newPassthru; } // lib.optionalAttrs (leaveDotGit != null) { inherit leaveDotGit; } else { url = "${baseUrl}/archive/${rev}.tar.gz"; - passthru = { + passthru = newPassthru // { inherit gitRepoUrl; }; } ) // privateAttrs // passthruAttrs // { inherit name; }; in -fetcher fetcherArgs // { meta = newMeta; inherit rev owner repo; } +(fetcher fetcherArgs).overrideAttrs (finalAttrs: previousAttrs: { + meta = newMeta; +}) )