New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: More common updater script implementations #21766
Conversation
I prefer generating separate JSON file. I should have done so for Firefox/Thunderbird. After all, we need rewrite each packages to adopt |
Of course, this update script is far better than my ad hoc update script using |
I think in a large number of cases rewriting the packages is not necessary and things like figuring out the latest version can be automated. E.g. if a package is currently using (This is the similar logic what http://monitor.nixos.org/ used to do when it was up and I found it very useful). |
name = "thunderbird"; | ||
sourceSectionRegex = "."; | ||
basePath = "pkgs/applications/networking/mailreaders/thunderbird"; | ||
passthru.updateScript = callPackage ./../../browsers/firefox/update.nix { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an abuse of callPackage
. update.nix
is not a package...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have the same thing under a different name? It's quite painful to duplicate the list of upgrade script dependencies four times.
#! nix-shell --pure -p bash nix coreutils gawk gnused -i bash | ||
set -e | ||
|
||
# FIXME: It's dumb that this is needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise this happens (on NixOS):
error: Nix database directory ‘/nix/var/nix/db’ is not writable: Permission denied
./maintainers/scripts/common-updater/update-source-version: error: Couldn't evaluate 'thunderbird.meta.position' to locate the .nix file!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not a fan of using nix-shell inside nix-shell. i would rather have this common-scripts become packages in nixpkgs (under some namespace) and which we run them using maintainers/scripts/update.nix
This looks basically good to me. Having a 90-line shell script full of grep/sed magic is not ideal but that could be improved in the future. (I'm thinking that ideally, we would have |
@garbas I agree. @dezgeg Regarding |
Okay, thank you for the feedback. I've now moved this to |
Adds a script to help automatically upgrading packages: this one can patch name/version attributes like: version = "50.1.0"; name = "bc-1.06"; ... to the given version, and updates the sha256 hash to match. Usage is: update-source-version <attr> <new-version> [<new-source-hash>] where: - attr is the attribute path of the package - new-version is the version string to be patched in - new-source-hash is the optional sha256/etc. hash of the source. If not given, the script will automatically calculate it. This is added to a subdirectory where other useful scripts can be added in the future, like figuring out the newest version from a git repo or GitHub releases etc.
This way we have the benefit of the usual Nixpkgs style, and gain a slight reduction in amount of code in the updater. Also use callPackage to reduce duplication of the dependencies of the update script and use makeBinPath to make things neater.
Replace the custom patching code with the common script. Also use callPackage and makeBinPath
Any issues with the updated version? |
I have pushed this as it also fixes the |
As a first step of adding some common updater script implementations, this PR adds a script to automate patching the
version
andsha256
fields in .nix files. It currently uses the hacky way of replacing the existing hash with an invalid one and parsing the proper hash from the error message. When NixOS/nix#1172 is fixed,nix-build --hash
can be used.Now, others have proposed (and used) different and arguably cleaner approaches than patching the .nix files, like generating separate JSON files for sources (e.g. #21734). But from a pragmatic point of view, we already have thousands of packages using the traditional "version/sha in .nix file" style, so it likely makes sense to make the tooling work with those instead of trying to convert all of them.
cc @garbas for the
tp_smapi
stuff and @taku0 for the Firefox/Thunderbird stuff. Also @edolstra for the general approach & locations of the scripts.For easier testing, here are the same commits + the relevant packages downgraded: https://github.com/dezgeg/nixpkgs/commits/updater-downgraded