Many, many people have ran into this frustrating issue around “I updated the version, why does it say the old version when I run the application” when using FODs. I targeted the most popular fetch first, fetchFromGitHub
.
Anyway, if anyone has any strong objections, please let me know. I’m trying my hardest to get this pushed through since there’s a lot of inflight changes, and I don’t want to deal with massive amounts of conflicts.
NixOS:staging
← jonringer:avoid-fetchfromgithub-footgun
opened 08:16PM - 03 Jan 22 UTC
###### Motivation for this change
Just giving the derivation a name of "sourc… e" by default causes
a lot of pain when someone may update the rev, but fail to
compute the new sha256 or invalidate the existing sha256. A stale
sha256 will still be "valid" in the eyes of nix, as only the way
in which the sources are fetched has changed, but the previous
.drv and sha256 relationship is still preserved.
This change forces the FODs to be recomputed as the related .drv
has changed.
This will not require all of the FOD sha256s to be recomputed, as
the contents will not have changed. However, it will be a mass
rebuild as it will create a new DAG for packages which didn't
already pass a "name" value to fetchFromGitHub.
```
# previous sha256 is still valid
$ nix-build -A nix-template.src --check
checking outputs of '/nix/store/ib74331l6pl6f8s2hsakf68lhg2jsl5i-nix-template-0.1.4-src.drv'...
trying https://github.com/jonringer/nix-template/archive/v0.1.4.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 130 100 130 0 0 425 0 --:--:-- --:--:-- --:--:-- 426
100 27955 0 27955 0 0 36653 0 --:--:-- --:--:-- --:--:-- 311k
unpacking source archive /build/v0.1.4.tar.gz
/nix/store/lfbgmqvpq5365q5ivv6ccck7xg88syw5-nix-template-0.1.4-src
# explicit commit hash example
$ nix-build -A artyFX.src
this derivation will be built:
/nix/store/ir4k3n5q7nmb2wh533pq1ma1cabyr8h7-openAV-ArtyFX-8c542627d9-src.drv
building '/nix/store/ir4k3n5q7nmb2wh533pq1ma1cabyr8h7-openAV-ArtyFX-8c542627d9-src.drv'...
trying https://github.com/openAVproductions/openAV-ArtyFX/archive/8c542627d936a01b1d97825e7f26a8e95633f7aa.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 173 100 173 0 0 754 0 --:--:-- --:--:-- --:--:-- 755
100 627k 0 627k 0 0 604k 0 --:--:-- 0:00:01 --:--:-- 1014k
unpacking source archive /build/8c542627d936a01b1d97825e7f26a8e95633f7aa.tar.gz
/nix/store/dkvcfm90ckrlgmv89s8sr15vcidwlxhs-openAV-ArtyFX-8c542627d9-src
```
###### Things done
- Built on platform(s)
- [ ] x86_64-linux
- [ ] aarch64-linux
- [ ] x86_64-darwin
- [ ] aarch64-darwin
- [ ] For non-Linux: Is `sandbox = true` set in `nix.conf`? (See [Nix manual](https://nixos.org/manual/nix/stable/command-ref/conf-file.html))
- [ ] Tested, as applicable:
- [NixOS test(s)](https://nixos.org/manual/nixos/unstable/index.html#sec-nixos-tests) (look inside [nixos/tests](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests))
- and/or [package tests](https://nixos.org/manual/nixpkgs/unstable/#sec-package-tests)
- or, for functions and "core" functionality, tests in [lib/tests](https://github.com/NixOS/nixpkgs/blob/master/lib/tests) or [pkgs/test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/test)
- made sure NixOS tests are [linked](https://nixos.org/manual/nixpkgs/unstable/#ssec-nixos-tests-linking) to the relevant packages
- [ ] 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](https://github.com/Mic92/nixpkgs-review#usage)
- [ ] Tested basic functionality of all binary files (usually in `./result/bin/`)
- [22.05 Release Notes (or backporting 21.11 Release notes)](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#generating-2205-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
- [ ] (Release notes changes) Ran `nixos/doc/manual/md-to-db.sh` to update generated release notes
- [ ] Fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
9 Likes
hmmm, if you talking about nixpkgs, could catching these mistakes be done in a CI job?
When i first started with nix, i came across this problem with FOD’s. There were no warnings to help me, nix just did it’s thing. So i can understand its is annoying. It really stumped me, until i kind soul helped me out on IRC.
I’m not sure you could even warn via nix-build or ‘nix build’ because it has no concept of any previous .drv files. Maybe it could look for previous .drv files for the derivation , and compare if source has been changed, but the sha256 has is the same, and print a rather big warning… in red. in CAPS, and with lots of ****** around it
1 Like
NobbZ
January 4, 2022, 11:40am
3
I really like this!
Especially as this might also shed some light on all those *-source
folders in the store that I am not sure where or why they come from, but also don’t get collected on a GC.
6 Likes
NobbZ
July 4, 2022, 6:43am
4
Due to a discussion in the chat I came back looking for the status of the PR and I have seen that it has not rellay been touched since March.
Is there any timeframe for getting this merged?
1 Like
No, normalization of FODs has taken precedence over user experience.
I don’t really have the fight to continue the issue.
1 Like
NobbZ
July 4, 2022, 11:00am
6
So, as I understand you now, the issue can basically closed as a “wont do”?
This is sad
2 Likes