Skip to content

fetchFromGitHub: re-fetch upon version changes - #294068

Draft
ShamrockLee wants to merge 3 commits into
NixOS:stagingfrom
ShamrockLee:fetchgithub-refetch
Draft

ShamrockLee wants to merge 3 commits into
NixOS:stagingfrom
ShamrockLee:fetchgithub-refetch

Conversation

@ShamrockLee

@ShamrockLee ShamrockLee commented Mar 7, 2024 •

Copy link
Copy Markdown
Contributor

Description of changes

This PR mitigates the development issue of irrelevent FOD hashes after version bump/version overriding, by making rev part of the store path through the default value of the name attribute.

Depends on #294329 and #294334. Once they're merged, there will be only one commit and two changed files (including the release note) in this PR.

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, as applicable:
  • 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
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions Bot added 8.has: documentation This PR adds or changes documentation 6.topic: fetch Fetchers (e.g. fetchgit, fetchsvn, ...) labels Mar 7, 2024
@ShamrockLee
ShamrockLee changed the base branch from master to staging March 7, 2024 15:21
@ShamrockLee
ShamrockLee force-pushed the fetchgithub-refetch branch from c2f6d70 to 65a152b Compare March 7, 2024 15:47
@ShamrockLee
ShamrockLee changed the base branch from staging to master March 7, 2024 16:01
@ShamrockLee
ShamrockLee force-pushed the fetchgithub-refetch branch from 65a152b to c0ae33f Compare March 7, 2024 17:16
@github-actions github-actions Bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog This PR adds or changes release notes labels Mar 7, 2024
@ofborg ofborg Bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Mar 7, 2024
@ShamrockLee ShamrockLee changed the title fetchFromGitHub: support version and re-fetch upon version/rev changes fetchFromGitHub: support version and re-fetch upon version changes Mar 7, 2024
@ShamrockLee
ShamrockLee force-pushed the fetchgithub-refetch branch from c0ae33f to 70bc532 Compare March 7, 2024 19:15
@ShamrockLee

Copy link
Copy Markdown
Contributor Author

@ofborg build archivebox python311Packages.jwt python312Packages.jwt

@ShamrockLee
ShamrockLee changed the base branch from master to staging March 7, 2024 21:28
@ShamrockLee
ShamrockLee force-pushed the fetchgithub-refetch branch from 70bc532 to 56cc63c Compare March 7, 2024 21:42
@ShamrockLee

Copy link
Copy Markdown
Contributor Author

@ofborg build cowsay

@ShamrockLee

Copy link
Copy Markdown
Contributor Author

@ofborg build nixdoc

@github-actions github-actions Bot added the 6.topic: python Python is a high-level, general-purpose programming language. label Mar 8, 2024
@ShamrockLee
ShamrockLee force-pushed the fetchgithub-refetch branch 2 times, most recently from 08f6449 to 3b8b903 Compare March 8, 2024 17:37
@github-actions github-actions Bot added the 6.topic: vim Advanced text editor label Mar 8, 2024
@ShamrockLee ShamrockLee changed the title fetchFromGitHub: support version and re-fetch upon version changes fetchFromGitHub: re-fetch upon version changes Mar 8, 2024
@ShamrockLee

Copy link
Copy Markdown
Contributor Author

Let's limit the scope of this PR and avoid changing the interface too much.

@ShamrockLee
ShamrockLee force-pushed the fetchgithub-refetch branch 3 times, most recently from 408e863 to f893a82 Compare March 8, 2024 18:27
@ofborg ofborg Bot added 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. labels Mar 8, 2024
@ghost

ghost commented Mar 10, 2024

Copy link
Copy Markdown

nixpkgs-review shows no evaluation error. The ofborg-eval-lib-tests is due to failure to bootstrap its own tool chain.

I couldn't find a way to reproduce the build failure as well. Even llvm builds alright locally.

ofborg-eval-lib-tests failure
   ran test tests/add.sh... [FAIL]
    ++ nix-store --add ./dummy
    + path1=/build/nix-test/add/store/n7knm3rma6fckrfwkx2vkiql3d1rgs1i-dummy
    + echo /build/nix-test/add/store/n7knm3rma6fckrfwkx2vkiql3d1rgs1i-dummy
    /build/nix-test/add/store/n7knm3rma6fckrfwkx2vkiql3d1rgs1i-dummy
    ++ nix-store --add-fixed sha256 --recursive ./dummy
    + path2=/build/nix-test/add/store/n7knm3rma6fckrfwkx2vkiql3d1rgs1i-dummy
    + echo /build/nix-test/add/store/n7knm3rma6fckrfwkx2vkiql3d1rgs1i-dummy
    /build/nix-test/add/store/n7knm3rma6fckrfwkx2vkiql3d1rgs1i-dummy
    + test /build/nix-test/add/store/n7knm3rma6fckrfwkx2vkiql3d1rgs1i-dummy '!=' /build/nix-test/add/store/n7knm3rma6fckrfwkx2vkiql3d1rgs1i-dummy
    ++ nix-store --add-fixed sha256 ./dummy
    + path3=/build/nix-test/add/store/1b0chpd74drqysiwsskw53zwlg18rcjl-dummy
    + echo /build/nix-test/add/store/1b0chpd74drqysiwsskw53zwlg18rcjl-dummy
    /build/nix-test/add/store/1b0chpd74drqysiwsskw53zwlg18rcjl-dummy
    + test /build/nix-test/add/store/n7knm3rma6fckrfwkx2vkiql3d1rgs1i-dummy '!=' /build/nix-test/add/store/1b0chpd74drqysiwsskw53zwlg18rcjl-dummy
    ++ nix-store --add-fixed sha1 --recursive ./dummy
    + path4=/build/nix-test/add/store/dgvdyhjxyg2ychmw8nm1vb0cdszqqnyr-dummy
    + echo /build/nix-test/add/store/dgvdyhjxyg2ychmw8nm1vb0cdszqqnyr-dummy
    /build/nix-test/add/store/dgvdyhjxyg2ychmw8nm1vb0cdszqqnyr-dummy
    + test /build/nix-test/add/store/n7knm3rma6fckrfwkx2vkiql3d1rgs1i-dummy '!=' /build/nix-test/add/store/dgvdyhjxyg2ychmw8nm1vb0cdszqqnyr-dummy
    ++ nix-store -q --hash /build/nix-test/add/store/n7knm3rma6fckrfwkx2vkiql3d1rgs1i-dummy
    + hash1=sha256:0lc8c8k1yc8m563wxg9ikalz4q9f56gc667qnnsjiwgiv7ya8xbw
    + echo sha256:0lc8c8k1yc8m563wxg9ikalz4q9f56gc667qnnsjiwgiv7ya8xbw
    sha256:0lc8c8k1yc8m563wxg9ikalz4q9f56gc667qnnsjiwgiv7ya8xbw
    ++ nix-hash --type sha256 --base32 ./dummy
    + hash2=0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p
    + echo 0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p
    0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p
    + test sha256:0lc8c8k1yc8m563wxg9ikalz4q9f56gc667qnnsjiwgiv7ya8xbw = sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p
make: *** [mk/lib.mk:128: tests/add.sh.test] Error 1
make: *** Waiting for unfinished jobs....

i've seen this failure before and filed a bug: #294433

full log: https://gist.githubusercontent.com/GrahamcOfBorg/a54aaa359754668dc899a98c49f6db7f/raw/6d8ed13eda6981f76fcffded3cadc6ff43f06795/ofborg-eval-lib-tests

re-runing the eval usually clears it:
@ofborg eval

@ShamrockLee

ShamrockLee commented Mar 10, 2024 •

Copy link
Copy Markdown
Contributor Author

I'm running nix-build --arg pkgs import ./. {} ./lib/tests/release.nix locally on my laptop. There are chances of failure caused by network issue during source fetching, and this PR changes a bunch of FOD out path, implying a whole lot of re-fetches. It takes multiple re-running to fetch all of them when the network connection is less than ideal.

@ShamrockLee

Copy link
Copy Markdown
Contributor Author

Update: Manual run on my x86_64-linux NixOS laptop succeeded.

Command: nix-build --arg pkgs "import ./. {}" ./lib/tests/release.nix --no-out-link

@ShamrockLee

Copy link
Copy Markdown
Contributor Author

@ofborg eval

Take optional argument `passthru` for custom passthru attribute set.

Update the `meta` attribute via `<pkg>.overrideAttrs` instead of
attribute set update (`//`).

Attach attributes `owner`, `repo` and `rev` via `passthru` instead of
attribute set update.
Prefix the default value of `name` with `rev` to force re-fetch
everytime `rev` changes.
@ShamrockLee
ShamrockLee force-pushed the fetchgithub-refetch branch from f1db6e9 to b6f434c Compare March 14, 2024 07:40
@github-actions github-actions Bot removed 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: vim Advanced text editor labels Mar 14, 2024
@ShamrockLee

Copy link
Copy Markdown
Contributor Author

Bump as #294334 is merged and has headed staging.

@ShamrockLee

Copy link
Copy Markdown
Contributor Author

@ofborg eval

@lheckemann

Copy link
Copy Markdown
Member

Similar changes were rejected previously: #59858 (review)

@ShamrockLee

ShamrockLee commented Mar 23, 2024 •

Copy link
Copy Markdown
Contributor Author

Similar changes were rejected previously: #59858 (review)

@lheckemann Thanks a lot for this information!

Things have changed a lot this five years. We don't even have stdenv.mkDerivation and <pkg>.overrideAttrs taking finalAttrs back then. As Nixpkgs Manual explicitly specifies that sourceRoot must be formed using ${src.name} for fetchgit-based src and deprecates the src.name == "source" assumption, the rejection is no longer valid.

@eclairevoyant

eclairevoyant commented Mar 23, 2024 •

Copy link
Copy Markdown
Contributor

Actually the concern we have now was the same concern from 7 years ago 🙃

At least for me descriptive names in /nix/store are important (for example if I want to look at the sources of a package that I've recently built I just ls -d /nix/store/*name*), and independence of the hash from the fetch method is not

And now every nix user gets to trip on FOD moments, so badly that we have to warn them in the manual about it.

Anyway maybe the new RFC will help sort it.

@nixos-discourse

Copy link
Copy Markdown

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

https://discourse.nixos.org/t/puzzling-behavior-of-fetchfromgithub-with-submodules/48911/3

@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jan 2, 2025
@nixos-discourse

Copy link
Copy Markdown

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

https://discourse.nixos.org/t/fix-your-fods-fods-and-security/71531/3

@nixpkgs-ci nixpkgs-ci Bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 30, 2025
@nixpkgs-ci nixpkgs-ci Bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 29, 2026
@mdaniels5757 mdaniels5757 mentioned this pull request May 19, 2026
3 of 14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: merge conflict This PR has merge conflicts with the target branch 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: fetch Fetchers (e.g. fetchgit, fetchsvn, ...) 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants