Open
Conversation
pilz0
reviewed
Jun 18, 2025
774d318 to
63e9348
Compare
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/prs-ready-for-review/3032/5635 |
63e9348 to
830b0b7
Compare
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
Add a hook that would fix a common issue with projects using Versioneer
on GitHub: when GitHub runs analog of `git archive` to generate an
archive from a tag, it subsitutes `$Format:%d$` with `(HEAD -> main,
tag: the_tag)` when the tag points to the latest commit, but when more
commits are added, it becomes `(tag: the_tag)`, which changes source
hash.
Packages that are either automatically or manually updated early, get
source with this `HEAD -> main` part and so their sources are not
reproducible more often.
Adding this hook to projects that use Versioneer will remove this
`HEAD -> main` part of the description string and make the source
reproducible. Here's how it would look, for example:
src = fetchFromGitHub {
owner = "ANCPLabOldenburg";
repo = "ancp-bids";
tag = version;
hash = "sha256-vmw8SAikvbaHnPOthBQxTbyvDwnnZwCOV97aUogIgxw=";
nativeBuildInputs = [ fixVersioneerSourcesHook ];
};
I ran into this issue when preparing
NixOS#416464, the general case of this
issue is described in NixOS#84312.
Also fix resulting hash, which now matches the current tarball.
Also fix resulting hash, which now matches the current tarball.
830b0b7 to
4d6204a
Compare
16 tasks
YorikSar
added a commit
to tweag/nixpkgs
that referenced
this pull request
Aug 8, 2025
This option fetches tarball from GitHub based on tree hash instead of the tag to get unprocessed data from the repo, and then applies a partial implementation of `export-subst` to replace certain format strings, but unlike Git uses reproducible values for them. This includes an example of using this in a package affected by this non-reproducibility. Related PR: NixOS#417859 Related issue: NixOS#84312 Inspired by discussion: https://discourse.nixos.org/t/fetchfromgithub-and-the-versioneer-fixing-source-reproducibility/66539
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a hook that would fix a common issue with projects using Versioneer on GitHub: when GitHub runs analog of
git archiveto generate an archive from a tag, it subsitutes$Format:%d$with(HEAD -> main, tag: the_tag)when the tag points to the latest commit, but when more commits are added, it becomes(tag: the_tag), which changes source hash.Packages that are either automatically or manually updated early, get source with this
HEAD -> mainpart and so their sources are not reproducible more often.Adding this hook to projects that use Versioneer will remove this
HEAD -> mainpart of the description string and make the source reproducible. Here's how it would look, for example:I ran into this issue when preparing #416464, the general case of this issue is described in #84312.
To see which Python packages are using Versioneer, I ran following script:
find-versioneer.sh
And it produced the following list of packages that most likely have unstable source hashes after each release:
Packages
Trying to rebuild all of them, I got following packages with broken hashes:
Packages with broken sources
I've added the hook to some packages and fixed hashes if they were broken to show some examples. I picked a small number of packages with no dependants to avoid mass rebuild.
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usageAdd a 👍 reaction to pull requests you find important.