Skip to content

python3Packages.msgspec: fix src hash#416464

Merged
wolfgangwalther merged 1 commit intoNixOS:stagingfrom
tweag:msgspec-fix-hash
Sep 11, 2025
Merged

python3Packages.msgspec: fix src hash#416464
wolfgangwalther merged 1 commit intoNixOS:stagingfrom
tweag:msgspec-fix-hash

Conversation

@YorikSar
Copy link
Contributor

@YorikSar YorikSar commented Jun 13, 2025

The source hash changes because they use $Format:%d$ in their code, and GitHub can substitute this with different things in different times, see #84312.

In this case, the diff looks like this:

diff -ur /nix/store/v2yfg05q83i154bdi2s96g21zi079rgi-source/msgspec/_version.py /nix/store/94zddrfms1ikx61i0plxnqdd3gavfdzr-source/msgspec/_version.py
--- /nix/store/v2yfg05q83i154bdi2s96g21zi079rgi-source/msgspec/_version.py      1970-01-01 00:00:01.000000000 +0000
+++ /nix/store/94zddrfms1ikx61i0plxnqdd3gavfdzr-source/msgspec/_version.py      1970-01-01 00:00:01.000000000 +0000
@@ -24,7 +24,7 @@
     # setup.py/versioneer.py will grep for the variable names, so they must
     # each be defined on a line of their own. _version.py will just call
     # get_keywords().
-    git_refnames = " (HEAD -> main, tag: 0.19.0)"
+    git_refnames = " (tag: 0.19.0)"
     git_full = "dd965dce22e5278d4935bea923441ecde31b5325"
     git_date = "2024-12-27 11:06:58 -0600"
     keywords = {"refnames": git_refnames, "full": git_full, "date": git_date}

Fix the hash and add a comment explaining the situation.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other contributing documentation in corresponding paths.

Add a 👍 reaction to pull requests you find important.

@nix-owners nix-owners bot requested a review from fabaff June 13, 2025 14:43
@github-actions github-actions bot added 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 1001-2500 This PR causes many rebuilds on Darwin and should most likely target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 2501-5000 This PR causes many rebuilds on Linux and should target the staging branches. 6.topic: python Python is a high-level, general-purpose programming language. labels Jun 13, 2025
The source hash changes because they use `$Format:%d$` in their code,
and GitHub can substitute this with different things in different times,
see NixOS#84312.

In this case, the diff looks like this:

```
diff -ur /nix/store/v2yfg05q83i154bdi2s96g21zi079rgi-source/msgspec/_version.py /nix/store/94zddrfms1ikx61i0plxnqdd3gavfdzr-source/msgspec/_version.py
--- /nix/store/v2yfg05q83i154bdi2s96g21zi079rgi-source/msgspec/_version.py      1970-01-01 00:00:01.000000000 +0000
+++ /nix/store/94zddrfms1ikx61i0plxnqdd3gavfdzr-source/msgspec/_version.py      1970-01-01 00:00:01.000000000 +0000
@@ -24,7 +24,7 @@
     # setup.py/versioneer.py will grep for the variable names, so they must
     # each be defined on a line of their own. _version.py will just call
     # get_keywords().
-    git_refnames = " (HEAD -> main, tag: 0.19.0)"
+    git_refnames = " (tag: 0.19.0)"
     git_full = "dd965dce22e5278d4935bea923441ecde31b5325"
     git_date = "2024-12-27 11:06:58 -0600"
     keywords = {"refnames": git_refnames, "full": git_full, "date": git_date}
```

Fix the hash and add a comment explaining the situation.
@YorikSar YorikSar changed the base branch from master to staging June 13, 2025 15:14
@nixpkgs-ci nixpkgs-ci bot closed this Jun 13, 2025
@nixpkgs-ci nixpkgs-ci bot reopened this Jun 13, 2025
@wolfgangwalther
Copy link
Contributor

wolfgangwalther commented Jun 13, 2025

Re-running CI due to a odd failure fixed in #416448

(the fix wasn't on staging earlier, yet)

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/fetchfromgithub-and-the-versioneer-fixing-source-reproducibility/66539/1

YorikSar added a commit to tweag/nixpkgs that referenced this pull request Jul 21, 2025
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.
Copy link
Contributor

@Erethon Erethon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran into this myself, this fixes it and LGTM, thank you.

@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Sep 11, 2025
@wolfgangwalther wolfgangwalther merged commit b497d78 into NixOS:staging Sep 11, 2025
52 of 57 checks passed
@nixpkgs-ci
Copy link
Contributor

nixpkgs-ci bot commented Sep 11, 2025

Successfully created backport PR for staging-25.05:

@github-actions github-actions bot added the 8.has: port to stable This PR already has a backport to the stable release. label Sep 11, 2025
@YorikSar YorikSar deleted the msgspec-fix-hash branch September 11, 2025 11:03
@vcunat
Copy link
Member

vcunat commented Sep 11, 2025

Man, using $Format:%d$ makes things so ugly...

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

Labels

6.topic: python Python is a high-level, general-purpose programming language. 8.has: port to stable This PR already has a backport to the stable release. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 1001-2500 This PR causes many rebuilds on Darwin and should most likely target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 2501-5000 This PR causes many rebuilds on Linux and should target the staging branches. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants