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
emacs-modes: replace melpa-generated with json format + updater in emacs lisp #59189
Conversation
It would be good to collect some performance stats on this. Basically counting how long |
I can get some, later. Right now I'm in the middle of a couple of rebuilds and don't wan't to GC. The PR should be in a perfectly usable state, if you want to take a look. Subjectively, |
This is awesome work! Thanks! I'd like to get an opinion on this from @ttuegel before feeling comfortable about moving away from emacs2nix. |
@matthewbauer A completely unscientific test: $ time nix-env -f '<nixpkgs>' -qa -A emacsPackagesNg Master:
This PR:
$ time nix-instantiate '<nixpkgs>' -A emacsPackagesNg.magit Master:
This PR:
While both of the results from this PR are faster it's imho a negligible difference. |
Ha, seems like nix has a fast JSON reader built in ;-) Any significant difference in performance would surprise me, since the computed nix expressions remained pretty much the same. |
Here is a test script for timing nix-instantiate: #!/bin/sh -ex
instantiate () {
echo -n "Instantiated count "
nix-instantiate -E "
with import ./. { config = { allowBroken = true; }; };
emacsPackagesNg.melpaPackages
" 2>/dev/null | wc -l
}
(
cd master
echo "============================
On master"
nix-store --option keep-derivations false --gc 2>/dev/null
time instantiate
)
(
cd emacs-updater-elisp
echo "============================
On emacs-updater-elisp"
nix-store --option keep-derivations false --gc 2>/dev/null
time instantiate
) the output on my machine is
So it seems, we are a little bit slower, but times on my machine fluctuate heavily (15-25 seconds) |
ping @ttuegel |
I am currently developing a new branch of emacs2nix with the aim of producing an overlay which updates automatically. I don't really like maintaining such a large set of generated packages in Nixpkgs itself. I also haven't been a very responsive maintainer (new baby, dissertation, new full-time job, upcoming new baby... excuses, excuses) so I'm not going to be offended if Nixpkgs moves away from emacs2nix. Right now the packages are not kept up-to-date, so I say: if this can distribute the work of package updates, and if it seems to work, then ship it! |
@ttuegel thanks for your response. This PR isn't ready, yet, and as far as I'm concerned, it won't be before we can generate elpa and org packages as well. Now with your confirmation, I'll be glad to cherry-pick relevant commits into this PR.
This is a good point. The generator could have black-/whitelist capability, in order to maintain only a couple of necessary packages within nixpkgs and have the rest in overlays. Would this serve your purpose? It sounds like you might still keep working on emacs2nix, if we were to make the switch ... would you consider adopting the .json format in that case? |
Is this really true? In my experience the hard part about emacs packages is generating melpa. Org and elpa packages always worked perfectly with |
This may be true, but it would introduce another split (emacsPackages, emacsPackagesNg, melpa). Also, as I already mentioned, the integration of the json format from the nix side is a horrible hack and needs to be cleaned up. To be perfectly blunt: The issue for me is also about shared ownership. Replacing a solution where @ttuegel is the sole maintainer with a solution where I'm the sole maintainer makes little sense to me, neither from a community standpoint, nor from a standpoint of my own free time. So either somebody is going to jump in to help push this along (if this means pushing it out as is, so be it, at least I'll not be the only one receiving tickets about it), or it will have to wait until I get it to a state where I'm happy about releasing it, myself. |
f4d7183
to
14c37aa
Compare
I've updated to use extracted libraries and to handle melpa-stable. I think the melpa part should be mostly ready, now. Please give it a whirl. Does anybody care about some changed package names? e.g. |
c2ccb15
to
4c74432
Compare
@bendlas I've rebased and re-ran this. The generation works but building my configuration currently fails on cider-mode not passing sha256. I intend to make this usable (and hopefully closer to a mergable state) in the next couple of days. |
4c74432
to
cbae708
Compare
My errors were simply a side effect of running the generation on an unstable internet connection. @bendlas How do you feel about merging me merging this (providing ofborg gives thumbs up)? I think we just want to copy the name mappings from emacs2nix https://github.com/ttuegel/emacs2nix/blob/9143b374be02bd6220fd6317f1b72837ce8254bf/names.nix before we do the merge. cc'ing a few other known emacs users for testing |
It seems I still have some evaluation errors to sort out. We're making headway! edit: |
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've just tried to run ./update-melpa
, it took a while but the result seemed fine. And I can build packages: nix-build -A emacsPackagesNg.magit
Unless anyone requests changes I plan to merge this in 24 hours. edit: I have been running off of this PR for the last 2 days without issues (the previous evaluation errors for bitbucket was not affecting my personal configuration). |
I suggest cleaning up the commit history though, otherwise this could get annoying to run into while bisecting and it also doesn't adhere to the commit naming scheme we're trying to adhere to in nixpkgs |
@infinisil That was always the plan :) In fact I'll do that now. |
e99e032
to
f43ae5d
Compare
f43ae5d
to
e1b2d85
Compare
This approach has several differences with emacs2nix: - the updater uses a downloaded recipes.json and archive.json for commit information, it uses a local checkout only for hashing the recipes - the generated file is JSON - the updater is written in emacs lisp - prefetch errors are put into an error key in the JSON, for review + meta.broken attributes are generated from it The updater re-uses the existing generated file to memoize prefetched content-sha256s for commits, thus prefetching should normally be quite fast.
e1b2d85
to
d65f1b2
Compare
@bendlas Thanks for all your hard work in making this PR! I'm so happy about this change 😄 🎉 |
Awesome! Thanks for pushing this through! 🎉🎆 |
This approach has several differences with emacs2nix:
recipes.json
andarchive.json
for commit information, it uses a local checkout only for hashing the recipeserror
key in the JSON, for review +meta.broken
attributes are generated from itThe updater re-uses the existing generated file to memoize prefetched content-sha256s for commits, thus prefetching should normally be quite fast. The main bottleneck seems to be the
git log
call to determine the latest commit id per recipe file.I think having the updater written in emacs lisp increases the chances of getting it adopted by Nix' Emacs users, as well as possibilities to integrate more deeply with the melpa library.
To be clear, this is a review request. If people would rather stick with emacs2nix, I'd be happy to help with documenting / improving it.
cc
I want to get wide input from people interested in emacs in nixos, please excuse spam
#11503
#59153
@mdorman @phunehehe
TODO:
emulate old renames (e.g.
0blayout
->_0blayout
)handle invalid names (e.g.
@
)add commitStable and sha256Stable and port melpa-stable-generated
add support for elpa and org
extract support code from melpa-packages.nix
Update instructions in
melpa-packages.nix
Fix evaluation errors
Fix bitbucket sources
if somebody could help track down the infinite recursion, that occurs when trying this .. <3