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

Preview: Emacs enhancements #7431

Closed
wants to merge 12 commits into from
Closed

Conversation

ttuegel
Copy link
Member

@ttuegel ttuegel commented Apr 17, 2015

This is a preview for the community of some changes to Emacs packaging I have been preparing. I have been using this for some time already and I hope there is still enough time to get it into NixOS 15.05. There are two large changes:

  1. Packages are generated automatically by downloading metadata from ELPA, Marmalade, MELPA, and org-mode ELPA.
  2. A wrapper is provided so that the expression emacsWithPackages [ pkgA pkgB ... ] provides an Emacs which knows about the specified packages.

I look forward to your feedback!

Package Generation

TL;DR: Automatically-updated expressions for 1822 Emacs packages.

The package metadata can be downloaded from any package.el-compatible server. An unholy mixture of Elisp and Haskell converts the S-expression downloaded from the server to JSON; along the way, all the packages are downloaded and hashed. This JSON is loaded into a Nix expression using builtins.fromJSON and a set of packages is born! Two package sets are provided, emacs-packages includes packages from ELPA, Marmalade, and stable MELPA, while emacs-packages-unstable adds packages from unstable MELPA and org-mode ELPA.

Features:

  • The package updater is fast. Downloading and hashing all the sources listed above, 1822 packages total, takes <10 minutes on my 7-year-old laptop over Wi-Fi. (The updater is a separate package and will be available shortly.)
  • Package metadata is updated incrementally, i.e. only new packages are downloaded and hashed. Incremental updates take 30-50 seconds.
  • The package expressions are built by the lovely melpaBuild.

Emacs Wrapper

The Emacs wrapper defines environments for Emacs without having packages installed in the user or system profiles. File collisions between packages and Emacs is a major cause of breakage. (I'm looking at you, org-mode!) Now, I just have this in my environment.systemPackages:

    (emacsWithPackages (with emacs-packages-unstable; [
      auctex company company-ghc diminish
      evil evil-leader flycheck git-auto-commit-mode
      git-timemachine haskell-mode helm magit
      markdown-mode monokai-theme
      org-plus-contrib rainbow-delimiters
      undo-tree use-package
    ]))

and everything Just Works!

The wrapper works by creating a custom site-start.el file which adds the packages to load-path and wrapping Emacs so the custom start-up file is found first. Adding packages to the load path this way comes at the price of start-up time: my load times increased about 5% (0.15 seconds) due to this change. Of course, all my packages actually work now, so that's a big bonus. Of course, it is still possible to use an un-wrapped Emacs, which will read packages from the user and system profiles as before.

Emacs packages are commonly distributed as single .el files. This
unpackCmd handles them correctly and sets up sourceRoot. Other sources
are treated in the default manner.
Expressions are generated from the metadata in
pkgs/top-level/emacs-packages.json. The packages from emacsPackages
which have metadata have been dropped. The remaining packages from
emacsPackages have been moved over to emacs-packages, and ported to
melpaBuild where that was easy to do.
@peti
Copy link
Member

peti commented Apr 17, 2015

Wow, this looks really nice!

@the-kenny
Copy link
Contributor

I don't think we should keep any packages from Melpa. Melpa uses daily snapshots - we just can't keep up with that.

@the-kenny
Copy link
Contributor

Oh wait - this PR doesn't include any predefined package sets? Sorry, misunderstood that.

We should definitely ship packages from Marmalade and Melpa-Stable though.

@jgeerds
Copy link
Member

jgeerds commented Apr 17, 2015

@ttuegel Great! 🍻

@the-kenny
Copy link
Contributor

Another thing: Is emacsWithPackages mandatory? I patched our Emacs some time ago to automatically search each entry in NIX_PROFILES so we should be able to just install packages via nix-env or environment.systemPackages.

Package collisions aside - I think we should support both.

@the-kenny
Copy link
Contributor

Oh, and: Great! Nice work!

@edolstra
Copy link
Member

Cool stuff :-)

Nitpick: emacs-packages should be emacsPackages IMHO, since the convention is to use camelCase for non-package variable names (like pythonPackages, haskellPackages, ...).

@ttuegel
Copy link
Member Author

ttuegel commented Apr 17, 2015

Oh wait - this PR doesn't include any predefined package sets? Sorry, misunderstood that.

We should definitely ship packages from Marmalade and Melpa-Stable though.

It defines emacs-packages for the stable packages (ELPA, Marmalade, stable MELPA) and emacs-packages-unstable for the unstable. I can probably live with dropping unstable MELPA, though.

@ttuegel
Copy link
Member Author

ttuegel commented Apr 17, 2015

Another thing: Is emacsWithPackages mandatory? I patched our Emacs some time ago to automatically search each entry in NIX_PROFILES so we should be able to just install packages via nix-env or environment.systemPackages.

emacsWithPackages is orthogonal to the package updates. If you install packages in the normal way, they will continue to work. In fact, I have not made emacsWithPackages completely pure. Emacs will still get packages from the active profiles, but it will only search there after the explicit package list is exhausted.

@domenkozar
Copy link
Member

Adding documentation tag - we should update nixos release notes and write documentation for Nixpkgs manual.

@jgeerds
Copy link
Member

jgeerds commented Apr 17, 2015

I can probably live with dropping unstable MELPA, though.

I find MELPA unstable very useful because a lot of emacs packages don't have a stable version. There are about 1400 packages without a declared version number, that's more than the half

@ttuegel
Copy link
Member Author

ttuegel commented Apr 17, 2015

I find MELPA unstable very useful because a lot of emacs packages don't have a stable version. There are about 1400 packages without a declared version number, that's more than the half

I think there's a way I can keep everyone happy here. I can give each repository a priority in the updater, such that packages from stable repositories are chosen over packages from unstable repositories regardless of their version. If a package is in both stable and unstable MELPA, we would take the stable version; otherwise, we would take the unstable version. I think the packages without stable versions are not updated very often, so there isn't too much version churn to keep up with. @geerds @the-kenny Would this satisfy both of you?

@jgeerds
Copy link
Member

jgeerds commented Apr 18, 2015

Would this satisfy both of you?

Yes, good idea!

@gridaphobe
Copy link
Contributor

First of all, thanks @ttuegel for working on this! I was going to start on my own version when I get back from my honeymoon, but you beat me to it :)

A couple comments:

  1. It would be nice if the PR also added https://github.com/ttuegel/elpa2nix as a derivation so us other emacs maintainers have slightly easier access :)
  2. I'm a bit concerned about keeping the package list up-to-date. I know melpa-unstable only keeps the most recent version (as was discussed above), but what about melpa-stable and gnu elpa, etc? If the package archives don't keep older versions around we may find ourselves with a regular source of broken packages, which could be especially problematic for stable branches of nixpkgs. My originally idea (which admittedly would only work for melpa) was to join their archive.json and recipes.json files to get the package metadata as well as the source info, and then build the archive from source using melpaBuild. This would circumvent any stale archive issues.

@ttuegel
Copy link
Member Author

ttuegel commented Apr 20, 2015

It would be nice if the PR also added https://github.com/ttuegel/elpa2nix as a derivation so us other emacs maintainers have slightly easier access :)

When it was finished, it was going to go on Hackage, where it would be kept up-to-date automatically, but...

I'm a bit concerned about keeping the package list up-to-date. I know melpa-unstable only keeps the most recent version (as was discussed above), but what about melpa-stable and gnu elpa, etc? If the package archives don't keep older versions around we may find ourselves with a regular source of broken packages, which could be especially problematic for stable branches of nixpkgs. My originally idea (which admittedly would only work for melpa) was to join their archive.json and recipes.json files to get the package metadata as well as the source info, and then build the archive from source using melpaBuild. This would circumvent any stale archive issues.

I hadn't considered that. The archives do not keep old versions, so what I'm doing simply won't work. And, as you point out, only MELPA exposes the information we need to build packages from the original source repositories; by my count, that's about half of the stable packages. Unless we want to mirror all these archives somewhere, there's really no way for us to capture all, or even most, of the available Emacs packages.

@ttuegel
Copy link
Member Author

ttuegel commented Apr 20, 2015

Thinking about it more, I see two paths forward:

  1. As @gridaphobe suggests, we use the MELPA recipes to build packages directly from the original source repositories.
  2. We can mirror the packages. Actually ELPA is well-behaved and keeps old versions, but it's the only one. Because Github has HTTP access to repositories, we could keep the mirrored files in a Git repository. (The packages are distributed as single Elisp files and small tar archives thereof; they are not very large files.) It would be simple to modify elpa2nix to update that repository when it downloads new packages. Each package version already has a unique filename, so we could keep old versions accessible through Github HTTP indefinitely.

The disadvantage to the first approach is that we miss all the ELPA and Marmalade packages; although MELPA is the most comprehensive archive, I think we would still miss about 1000 packages. I was initially against mirroring the packages. Now I think that although mirroring is a little ugly, the coverage gain may be worth it. Mirroring also lets us support our stable releases better: TeXLive has the same problem, and as a result, using TeX on a release branch is a slightly miserable experience.

I would appreciate some feedback here. I have to admit a bias: the first option above requires throwing out most of my efforts on elpa2nix! Am I crazy to consider mirroring the package archives?

@gridaphobe
Copy link
Contributor

I was similarly opposed in spirit to mirroring packages when I first started thinking about this, but as long as we're not breaking GitHub's ToS I think I can live with the kludginess 😄

@ttuegel
Copy link
Member Author

ttuegel commented Apr 20, 2015

I just reviewed the ToS, and nothing forbids it. The ToS remarks that you must be legally able to redistribute whatever content you put up. The packages are all open-source just to be on *ELPA, so that's not a problem. However, the ToS also warns that repositories may be suspended for bandwidth use exceeding the typical, so we may want to avoid that. That reduces our options to mirroring somewhere else, or using the MELPA recipes.

I think using the MELPA recipes is not so bad. There seems to be a lot of duplication between MELPA and Marmalade. (ELPA is small and seems to keep old versions around indefinitely, so I don't think we should worry about that.) The reason that stable MELPA is so small seems to be mainly that unstable MELPA has many different plugins from emacswiki that don't have proper, stable versions. Some of the Marmalade packages on MELPA don't seem to have properly tagged Git repositories; I'm not sure what to do about that. If users do want packages in Nixpkgs that aren't in MELPA, we can submit recipe PRs upstream. I don't have a problem being the Debian of Emacs packages! :)

@ttuegel
Copy link
Member Author

ttuegel commented Apr 21, 2015

To stem the tide of bug reports: yes, the packages generated this way become outdated too quickly. As explained above, I am abandoning elpa2nix. I think we should generate packages based on MELPA's recipes. I intend to work on that in the near future, but I am not working on it at this time. The Emacs wrapper is still useful, though, and I will push it to master when I figure out some byte-compiling issues.

@ttuegel ttuegel closed this Apr 21, 2015
@ttuegel
Copy link
Member Author

ttuegel commented Apr 21, 2015

OK, emacsWithPackages is in master.

@purcell
Copy link
Member

purcell commented Apr 22, 2015

MELPA maintainer here.

I think using the MELPA recipes is not so bad. There seems to be a lot of duplication between MELPA and Marmalade.

Yes, MELPA is generally a superset of Marmalade, except for a few exceptions. The exceptions are split between packages which we declined on quality grounds, and ones which have been manually uploaded from a non-version-controlled source or a make result, such that MELPA can't host/build them.

(ELPA is small and seems to keep old versions around indefinitely, so I don't think we should worry about that.)

In case it's an issue, I should mention that we don't keep old versions currently. We'd like to start keeping just a few old versions.

The reason that stable MELPA is so small seems to be mainly that unstable MELPA has many different plugins from emacswiki that don't have proper, stable versions. Some of the Marmalade packages on MELPA don't seem to have properly tagged Git repositories; I'm not sure what to do about that.

There's a MELPA issue somewhere for that: the right course of action is to chase up the upstream maintainers and get them to add tags.

There are also a few packages which are in SCM systems which MELPA Stable does not yet handle. For better or worse, we refuse to trust versions embedded in files, since they're simply unreliable. Emacswiki-hosted packages are unlikely to ever make it into MELPA Stable, for exactly that reason.

Overall, due to these issues, MELPA Stable is fairly hit-and-miss, since dependencies for a listed package can sometimes be completely missing. The MELPA maintainers don't use Stable ourselves, because MELPA itself is not at all unstable in practice, so Stable is there primarily by popular demand on an "as-is" basis. I think many MELPA Stable users also have MELPA enabled, so that they can explicitly install "stable" packages on a package-by-package basis, while still having all the dependencies available for installation.

If users do want packages in Nixpkgs that aren't in MELPA, we can submit recipe PRs upstream. I don't have a problem being the Debian of Emacs packages! :)

Yes, please pass recipes on to us.

Regarding this effort in general (which I applaud!), I should point out that sometimes packages get removed from MELPA or even renamed. Not sure what impact that is likely to have on you. (Renaming is tracked via :old-names in the corresponding recipes.)

@ttuegel
Copy link
Member Author

ttuegel commented Apr 22, 2015

In case it's an issue, I should mention that we don't keep old versions currently. We'd like to start keeping just a few old versions.

That won't be a problem for us. Originally, I was just reading packages/archive-contents for all of the package archives. Then it would have been a problem, but when I realized that only ELPA keeps old versions, I abandoned that plan. It's probably better that we get packages from the original source anyway--we have a 12 month support cycle, and I don't expect any server to keep old packages that long.

I think many MELPA Stable users also have MELPA enabled, so that they can explicitly install "stable" packages on a package-by-package basis, while still having all the dependencies available for installation.

Right, there was some user feedback about that when I planned to just track MELPA Stable. My plan now is to use all the recipes, keeping stable versions where there is one and falling back to unstable versions when there isn't. We will be keeping our own snapshots, so I don't think there's a problem tracking unstable versions, but it would have been difficult to track daily snapshots from MELPA.

Regarding this effort in general (which I applaud!), I should point out that sometimes packages get removed from MELPA or even renamed. Not sure what impact that is likely to have on you. (Renaming is tracked via :old-names in the corresponding recipes.)

I don't think this will impact us much. It's no problem to have many names refer to the same package (the current name and all of :old-names). If a package is removed from MELPA, we can always add it back to Nixpkgs manually if there is demand for it, but I imagine packages are removed for good reason. There are already several packages that we must maintain manually, anyway. (Usually because they must be kept in-sync with some dependency, like ghc-mod.)

@purcell
Copy link
Member

purcell commented Apr 22, 2015

Great, sounds like that's all in hand, then. Just ping me or file a MELPA issue if you need anything.

@oxij oxij mentioned this pull request Dec 6, 2015
endocrimes added a commit to endocrimes/nixpkgs that referenced this pull request Apr 11, 2020
This commit migrates the Nomad package from the 0.10.x line of releases
to 0.11.X.

This allows us to also bump the version of Go that is used to 1.14.x.
NOTE: 1.14.x will be needed for the rest of the 0.11.x releases as Nomad
only bumps patch versions of Go within a release series.

CHANGELOG:

FEATURES:

    Container Storage Interface [beta]: Nomad has expanded support
    of stateful workloads through support for CSI plugins.
    Exec UI: an in-browser terminal for connecting to running allocations.
    Audit Logging (Enterprise): Audit logging support for Nomad
    Enterprise.
    Scaling APIs: new scaling policy API and job scaling APIs to support external autoscalers
    Task Dependencies: introduces lifecycle stanza with prestart and sidecar hooks for tasks within a task group

BACKWARDS INCOMPATIBILITIES:

    driver/rkt: The Rkt driver is no longer packaged with Nomad and is instead
    distributed separately as a driver plugin. Further, the Rkt driver codebase
    is now in a separate
    repository.

IMPROVEMENTS:

    core: Optimized streaming RPCs made between Nomad agents [NixOSGH-7044]
    build: Updated to Go 1.14.1 [NixOSGH-7431]
    consul: Added support for configuring enable_tag_override on service stanzas. [NixOSGH-2057]
    client: Updated consul-template library to v0.24.1 - added support for working with consul connect. Deprecated vault_grace [NixOSGH-7170]
    driver/exec: Added no_pivot_root option for ramdisk use [NixOSGH-7149]
    jobspec: Added task environment interpolation to volume_mount [NixOSGH-7364]
    jobspec: Added support for a per-task restart policy [NixOSGH-7288]
    server: Added minimum quorum check to Autopilot with minQuorum option [NixOSGH-7171]
    connect: Added support for specifying Envoy expose path configurations [NixOSGH-7323] [NixOSGH-7396]
    connect: Added support for using Connect with TLS enabled Consul agents [NixOSGH-7602]

BUG FIXES:

    core: Fixed a bug where group network mode changes were not honored [NixOSGH-7414]
    core: Optimized and fixed few bugs in underlying RPC handling [NixOSGH-7044] [NixOSGH-7045]
    api: Fixed a panic when canonicalizing a jobspec with an incorrect job type [NixOSGH-7207]
    api: Fixed a bug where calling the node GC or GcAlloc endpoints resulted in an error EOF return on successful requests [NixOSGH-5970]
    api: Fixed a bug where /client/allocations/... (e.g. allocation stats) requests may hang in special cases after a leader election [NixOSGH-7370]
    cli: Fixed a bug where nomad agent -dev fails on Windows [NixOSGH-7534]
    cli: Fixed a panic when displaying device plugins without stats [NixOSGH-7231]
    cli: Fixed a bug where alloc exec command in TLS environments may fail [NixOSGH-7274]
    client: Fixed a panic when running in Debian with /etc/debian_version is empty [NixOSGH-7350]
    client: Fixed a bug affecting network detection in environments that mimic the EC2 Metadata API [NixOSGH-7509]
    client: Fixed a bug where a multi-task allocation maybe considered healthy despite a task restarting [NixOSGH-7383]
    consul: Fixed a bug where modified Consul service definitions would not be updated [NixOSGH-6459]
    connect: Fixed a bug where Connect enabled allocation would not stop after promotion [NixOSGH-7540]
    connect: Fixed a bug where restarting a client would prevent Connect enabled allocations from cleaning up properly [NixOSGH-7643]
    driver/docker: Fixed handling of seccomp security_opts option [NixOSGH-7554]
    driver/docker: Fixed a bug causing docker containers to use swap memory unexpectedly [NixOSGH-7550]
    scheduler: Fixed a bug where changes to task group shutdown_delay were not persisted or displayed in plan output [NixOSGH-7618]
    ui: Fixed handling of multi-byte unicode characters in allocation log view [NixOSGH-7470] [NixOSGH-7551]
@Artturin Artturin added 6.topic: documentation Meta-discussion about documentation and its workflow and removed old-label: documentation labels Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: enhancement 2.status: work-in-progress 6.topic: documentation Meta-discussion about documentation and its workflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants