Skip to content
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

melpaBuild: allow nix unstable version format #316726

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

jian-lin
Copy link
Contributor

@jian-lin jian-lin commented Jun 2, 2024

Before, an unstable version of melpaBuild has to be in MELPA format, which has some disadvantages:

  • existing update scripts cannot be reused1
  • it causes inconsistence.

This patch fixes that by allowing an unstable version to be in Nix format.

We heuristically detect if it is an unstable version in Nix format. If so, we convert it to MELPA format.

This does not bring evaluation performance overhead. Here is my benchmark result using hyperfine-1.18.0 and nix-2.18.1.

Without this patch:

Benchmark 1: NIXPKGS_ALLOW_BROKEN=1 nix eval --include nixpkgs=$PWD --file . emacs.pkgs.melpaPackages --apply 'pkgSet: map (drv: drv.drvPath) (builtins.filter (p: p.type or null == "derivation") (builtins.attrValues pkgSet))' --no-eval-cache >/dev/null
  Time (mean ± σ):      9.126 s ±  0.048 s    [User: 6.531 s, System: 0.997 s]
  Range (min … max):    9.056 s …  9.186 s    10 runs

With this patch applied:

Benchmark 1: NIXPKGS_ALLOW_BROKEN=1 nix eval --include nixpkgs=$PWD --file . emacs.pkgs.melpaPackages --apply 'pkgSet: map (drv: drv.drvPath) (builtins.filter (p: p.type or null == "derivation") (builtins.attrValues pkgSet))' --no-eval-cache >/dev/null
  Time (mean ± σ):      9.124 s ±  0.057 s    [User: 6.522 s, System: 1.011 s]
  Range (min … max):    9.040 s …  9.220 s    10 runs

Description of changes

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • 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
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 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
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@AndersonTorres
Copy link
Member

I believe this is an extra reason to merge #315949 :)

pkgs/build-support/emacs/melpa.nix Outdated Show resolved Hide resolved
@@ -96,17 +113,17 @@ genericBuild ({
-L "$NIX_BUILD_TOP/package-build" \
-l "$melpa2nix" \
-f melpa2nix-build-package \
$ename $version $commit
$ename $melpaVersion $commit
Copy link
Member

Choose a reason for hiding this comment

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

Does it really work? I am impressed!

Copy link
Contributor Author

@jian-lin jian-lin Jun 2, 2024

Choose a reason for hiding this comment

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

Not sure why you comment at this line. But yes, the whole PR works. You can try it out yourself :)

Copy link
Member

Choose a reason for hiding this comment

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

This was mostly a reaction of 50% skeptic plus 50% amazed.

@jian-lin jian-lin force-pushed the pr/improve-melpaBuild-version branch from f896f70 to ce114b6 Compare June 2, 2024 21:17
@jian-lin jian-lin marked this pull request as draft June 2, 2024 21:27
@jian-lin jian-lin force-pushed the pr/improve-melpaBuild-version branch from ce114b6 to ba7021a Compare June 2, 2024 21:28
@jian-lin jian-lin changed the base branch from master to staging June 2, 2024 21:29
Before, an unstable version of melpaBuild has to be in MELPA format,
which has some disadvantages:
- existing update scripts cannot be reused[1]
- it causes inconsistence.

This patch fixes that by allowing an unstable version to be in Nix
format.

We heuristically detect if it is an unstable version in Nix format.
If so, we convert it to MELPA format.

This does not bring evaluation performance overhead.  Here is my
benchmark result using hyperfine-1.18.0 and nix-2.18.1.

Without this patch:

Benchmark 1: NIXPKGS_ALLOW_BROKEN=1 nix eval --include nixpkgs=$PWD --file . emacs.pkgs.melpaPackages --apply 'pkgSet: map (drv: drv.drvPath) (builtins.filter (p: p.type or null == "derivation") (builtins.attrValues pkgSet))' --no-eval-cache >/dev/null
  Time (mean ± σ):      9.126 s ±  0.048 s    [User: 6.531 s, System: 0.997 s]
  Range (min … max):    9.056 s …  9.186 s    10 runs

With this patch applied:

Benchmark 1: NIXPKGS_ALLOW_BROKEN=1 nix eval --include nixpkgs=$PWD --file . emacs.pkgs.melpaPackages --apply 'pkgSet: map (drv: drv.drvPath) (builtins.filter (p: p.type or null == "derivation") (builtins.attrValues pkgSet))' --no-eval-cache >/dev/null
  Time (mean ± σ):      9.124 s ±  0.057 s    [User: 6.522 s, System: 1.011 s]
  Range (min … max):    9.040 s …  9.220 s    10 runs

[1]: https://github.com/NixOS/nixpkgs/blob/177c9eddadc6abbaf62a19c90cc27a9fcde08e2d/pkgs/applications/editors/emacs/elisp-packages/manual-packages/lsp-bridge/default.nix#L93-L108
@jian-lin jian-lin force-pushed the pr/improve-melpaBuild-version branch from ba7021a to ee46aa8 Compare June 2, 2024 21:29
@jian-lin jian-lin marked this pull request as ready for review June 2, 2024 21:30
@jian-lin jian-lin merged commit 905b774 into NixOS:staging Jun 3, 2024
20 checks passed
@jian-lin jian-lin deleted the pr/improve-melpaBuild-version branch June 3, 2024 00:23
@AndersonTorres
Copy link
Member

Why is this PR taking so long to land?

https://nixpk.gs/pr-tracker.html?pr=316726

@jian-lin
Copy link
Contributor Author

The current PR to update staging-next takes a bit more time than usual.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/why-is-emacs-lisp-framework-updates-taking-so-long-to-reach-unstable/47416/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants