common update script (do not merge, PR opened for comments)#20844
common update script (do not merge, PR opened for comments)#20844garbas merged 2 commits intoNixOS:masterfrom
Conversation
|
Do you want to call this |
|
@ttuegel 👍 makes sense (i'll batch suggestions and then implement them) |
|
Good idea to have a common interface to updating packages. While you said the Firefox example is still WIP, I wonder whether it is good practice to add dependencies of the update script to the function that builds the derivation. How about using a script with a nix-shell shebang instead? |
|
how about turning the update scripts into own derivations with own files, they could be a separate nix file, be called as a package and have the executable outputting the current data as version i wonder if there is way to evaluate actual nix paths without putting them into store (so the target/source file can be given as a file in addition it makes sense to be able to have update scripts as general packages also for example python/lua/ruby packages and others do share a very common way to obtain update metadata |
|
Last time I have tried to put a lot of stuff for an auto-updater into expressions, it started annoying people really quickly… So now I put stuff in a separate file near the expression. Maybe the size of the updater means it should be in a separate file. Of course, there are many reusable snippets around that could help reducing it size. This means that I will just write the updater as «call the existing update script» for my expressions. Also, do I understand correctly that every update-enabled expression needs its file path, and the example stores it in a non-standard format ( |
|
@FRidh 👎 on nix-shell shebang. and i tried to use them initially but i quickly needed more then what nix-shell shebang offered. @RonnyPfannschmidt @7c6f434c (update script in a separate file) as said firefox updateScript is still WIP, right now it was just easier for me to put it all in one file. Otherwise I would expect that if custom update script, and just one liner to create @RonnyPfannschmidt (general update script) I'm sure as we go we will have many common update scripts. example from my current code would be a script which "looks for latest revision in a branch" but i'm sure we'll invent some more @RonnyPfannschmidt (update multiple derivation) for those derivations where you need to manage versions "in harmony" a namespace should already exists. majority of packages already works this way, eg. @7c6f434c (every updateScript needs to call pushd) I don't like this part either, ideally i would do this pushd/popd from an i hope i answered all the questions / concerns |
|
@RonnyPfannschmidt (general update script) I'm sure as we go we will have many common update scripts. example from my current code would be a script which ["looks for latest revision in a branch"](https://github.com/mozilla-releng/services/blob/master/nix/tools/default.nix#L10) but i'm sure we'll invent some more
I am more for reusable snippets, we already have some to break out in
`nixpkgs-monitor`, some other scripts, my `update-walker`…
@7c6f434c (every updateScript needs to call pushd) I don't like this part either, ideally i would do this pushd/popd from an ``update.nix`` but I'm not sure it is possible to know the path of the expression. but i didn't look much into it. I would love to be proven wrong.
A separate attribute would already be an improvement.
Also we could try optionally instrumenting callPackage.
A change in Nix is also an option, but this would require some careful
design so that it doesn't allow leaking NixPkgs location into NixOS
instance hash.
|
How so? If I understand the Regarding the snippets, we could attach the |
|
Regarding the snippets, we could attach the `updateFromGitHub` to `fetchFromGitHub.update` and so have something like `passthru.updateScript = src.update;`. This we could do with most fetchers I suppose. By default they would write to `src.json` or `src.nix`.
```
mkDerivation {
src = fetchFromGitHub { }; # The arguments are in `src.nix`. `fetchFromGitHub` has `src ? src.nix`. Or do we still have issues with finding the path?
passthru.updateScript = src.update;
};
```
It is easy to update sha256 in-place (it is unique and it has no
interesting structure inside, after all), and I think source URLs should
refer to `version`, together with the name. Most of the packages contain
just one `version = ` line. I remember that having `src.nix` got people
annoyed last when I tried it, and updating the version in-place seems to
work just fine in my current experience with auto-updaters.
|
Can you link to this discussion? I use a |
|
how about having something like an alternativ would a surrounding tool that can edit fetchFromGithub expressions that are "simple? |
|
Not sure how to look it up easily… Maybe my need to store both update meta and source data in separate files was the most annoying part. |
|
As I said on the ML, I’d reserve the |
There was a problem hiding this comment.
cat > $tmpfile <<EOF
{
version = "$version";
sources = [
EOF
for arch in linux-x86_64 linux-i686; do
for line in `echo "$shasums" | grep $arch | grep "firefox-$version.tar.bz2$" | tr " " ":"`; do
cat >> $tmpfile <<EOF
{ url = "$url$version/$arch/`echo $line | cut -d":" -f3`";"
locale = "`echo $line | cut -d":" -f3 | sed "s/$arch\///" | sed "s/\/.*//"`";
 arch = "$arch";
sha512 = "`echo $line | cut -d":" -f1`";
}
EOF
done
cat >> $tmpfile <<EOF
];
}
EOFThere was a problem hiding this comment.
👍 your version look much more readable. will update PR shortly
|
@ttuegel @FRidh i tried to switch to @Profpatsch update attribute is not going to be used but @7c6f434c @FRidh this PR doesn't restrict none of your ideas about having update script with fetchFrom* functions. it is good to have this discussion, i'm just making it clear that nothing blocks this PR. the code has been rebased on current master and suggestions from @Mic92 were added. if no further concerns are raised i will merge this on Monday evening hawaii timezone. after that i plan to move my currently used update scripts to nixpkgs (in a separate PR). |
|
Why changing Could you do something about the |
|
I think the script should be attached to the passthru of Edit: anyway, it's not that important |
Yeah, then I’d reserve both |
|
@7c6f434c (meta) no idea what is happening to @7c6f434c (pushd) i don't see this as a blocker for this PR. while i would wish this could be done differently. It looks like instrumenting callPackage or even nix itself would be the way to go, but that would delay this PR unnecessary. @FRidh I would like it at the expression level, because sometimes you would want to update whole attribute set of packages (eg: using pypi2nix, elm2nix, ...). I already do this in few places outside nixpkgs and would like to bring this to nixpkgs. @Profpatsch sry, not sure I understand what you mean. this PR uses |
|
@7c6f434c (pushd) i don't see this as a blocker for this PR. while i would wish this could be done differently. It looks like instrumenting callPackage or even nix itself would be the way to go, but that would delay this PR unnecessary.
Well, having a separate attribute for the path-to-self and using it
doesn't require much change…
|
mkDerivation should provide a default updateScript that delegates to the derivation's src attribute. That way if we provide one for fetchFromGitHub then all the related derivations will support it.
The easiest way would be to split the fetchers so they import from a separate file. Then that file's path can be passed to the updater script. That's something I was exploring over at #19582 |
also added some comments to the update script so that a new person looking at it know what is happening
|
finally got around to merge this. since we are still figuring out how to do update i wont add anything to the manual (at this point) but only write to the mailing list explaining the functionality and show few examples. i assume before next release we might have something that we could document. |
|
|
|
I should have passed |
|
The wrapper script should probably propagate the updateScript though |
|
@zimbatm propagating |
|
Good point. Those would be uniquified away in the update.nix file. |
|
Few days ago I proposed on the mailing list to unify a way how we update packages. This is an initial attempt at that.
To update one package by attribute name run (from the root of
nixpkgsrepo):To update all package maintained by me (@garbas) then run:
I only implemented update script for
firefox-binsince it was on my list for quite some time (I replaced ruby with bash). I addedpassthru.updateScriptattribute tofirefox-binexpression which is expected to be executable script which updatednixpkgsto updated version offirefox-bin.passthru.updateScriptcan be implemented in any language. We should not limit that.nix-shell update.nix ...on their own. at later point we can automate this or not, we'll see.updateScriptforfirefox-binis ugly (I'll improve it later), but I just needed something to show of how I imagined update scripts to work. also and I had no clue how to change that ruby script.update.nixarguments are discussable. maybe we need few more maybe error outputs should be better. most likely the answer is yes. Lets discuss what should we add / remove / ...