Skip to content

fetchFromGitHub: use passthru instead of // to support overrideAttrs #370418

Closed

Description

@TomaSajt

Describe the bug

Currently fetchFromGitHub works like this:

{ ... }:
let
  ...
  
  fetcherArgs = (if useFetchGit
    then {
      inherit tag rev deepClone fetchSubmodules sparseCheckout fetchLFS; url = gitRepoUrl;
    } // lib.optionalAttrs (leaveDotGit != null) { inherit leaveDotGit; }
    else {
      url = "${baseUrl}/archive/${revWithTag}.tar.gz";


      passthru = {
        inherit gitRepoUrl;
      };
    }
  ) // privateAttrs // passthruAttrs // { inherit name; };
in


fetcher fetcherArgs // { meta = newMeta; inherit owner repo tag; rev = revWithTag; }

(see the entire file: https://github.com/NixOS/nixpkgs/blob/edb546d0e3884c526dab475224136637cae3f36f/pkgs/build-support/fetchgithub/default.nix#L64C1-L78C85)

unfortunately, the last line is messing up the overrideAttrs interface: because // is used on the derivation itself overrideAttrs doesn't know about their existance and thus deletes them if we try to .overrideAttrs the result of fetchFromGitHub.

Possible solution

passthru is a method for achieving the same thing, aka. appending extra information onto a derivation, but from the inside. It's also supported by overrideAttrs.

If we did

passthru = {
  inherit gitRepoUrl owner repo tag;
  meta = newMeta;
  rev = revWithTag;
};

it would be much better, however fetchgit currently doesn't support passing passthru, so we'd also need to change that.
(Though, meta should probably not be part of passthru if we did this)

Note

I know there's a .override interface over fetchFromGitHub, however that's not "generic" enough. .overrideAttrs should work with any kind of fetcher.
It would be amazing if we could be able to do something like this and not have to worry about implementation details of the src FOD.

Example:

some-package.overrideAttrs (prevAttrs: {
  version = "2.0";
  src = prevAttrs.src.overrideAttrs { outputHash = "new-hash"; };
})

Notify maintainers


Note for maintainers: Please tag this issue in your PR.


Add a 👍 reaction to issues you find important.

Activity

  1. added
    0.kind: bug
    on Jan 2, 2025
  2. philiptaron commented on Jan 3, 2025

    @philiptaron
    Contributor

    Yes!

  3. added
    2.status: stale
    on Jul 4, 2025
  4. ShamrockLee commented on Nov 27, 2025

    @ShamrockLee
    Contributor

    @TomaSajt Now that #456751 is merged. Could we close this issue?

  5. removed
    2.status: stale
    on Nov 27, 2025
  6. TomaSajt commented on Nov 28, 2025

    @TomaSajt
    ContributorAuthor

    Closed via #456751

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions