Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

fetchFromGitHub: force re-fetch when rev changes #11

Merged
merged 4 commits into from
May 21, 2024

Conversation

bbjubjub2494
Copy link
Contributor

Since we have yet to hit the ground running, we have a golden opportunity to fix some of those long-standing issues in upstream that don't get fixed to avoid disturbing the whole project. Specifically, this is the fact that fetchFromGitHub currently outputs a FOD with a very generic name. As a result, if a maintainer changes a version number but forgets about the output hash, it may not get caught. Error messages are also less useful. If we can fix that we will have much better DX moving forward.

To illustrate: I tried to rebuild nixdoc to see if it was working and I immediately caught a stale hash.

Based on NixOS/nixpkgs#294068

@isabelroses
Copy link
Member

Is this NixOS/nixpkgs@c3255fe8ec32#commitcomment-25289921, not a concern which lead the original PR maker to create NixOS/nixpkgs#294329

@bbjubjub2494
Copy link
Contributor Author

Is this NixOS/nixpkgs@c3255fe8ec32#commitcomment-25289921, not a concern which lead the original PR maker to create NixOS/nixpkgs#294329

This is true and those two commits are already included in the first PR as well as the present PR.

This change does not by itself invalidate all hashes. I checked the python3Packages.build hash and it was really stale to begin with.

@bbjubjub2494
Copy link
Contributor Author

Removing the fix hash commit to avoid conflicts

{ owner, repo, rev, name ? "source"
{ owner, repo, rev
, name ? null # Override with nullbto use the default value
, pname ? "source-${owner}-${repo}"
Copy link
Member

Choose a reason for hiding this comment

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

TBH, I'd also change source to something like github-repo, just to make it clearer in the name that the derivation comes from a GitHub checkout.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's a slightly different proposal: append the github base url as provenance like so: /nix/store/wzvnh3p7gv1qlqhb3iif878bfffzrvaz-source-pypa-build-refs-tags-1.1.1-github.com.drv. That's a good self-description, leaves the source that people might be used to, and generalizes unambiguously to other fetchFroms. We can also put it before the owner.

Copy link
Member

Choose a reason for hiding this comment

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

Only potential issue I see is creating some pretty long path names, but I don't see it being a massive issue. Seems fine to me.

Prefix the default value of `name` with `rev` to force re-fetch
everytime `rev` changes.
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.
@bbjubjub2494 bbjubjub2494 force-pushed the fetchgithub-refetch branch from 8c0a99d to 7494c65 Compare May 19, 2024 08:25
{ owner, repo, rev, name ? "source"
{ owner, repo, rev
, name ? null # Override with null to use the default value
, pname ? "source-${githubBase}-${owner}-${repo}"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

/nix/store/f291banfgj2vjz1qsvmpm09awn2gl4pj-source-github.com-pypa-build-refs-tags-1.1.1.drv wdyt @Sorixelle ?

@AxelSilverdew AxelSilverdew merged commit 7ec6274 into auxolotl:main May 21, 2024
@bbjubjub2494 bbjubjub2494 deleted the fetchgithub-refetch branch May 21, 2024 05:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants