Usage with Nix - progfolio/elpaca GitHub Wiki

Developer's Note

I do not use Nix. The information on this page has been contributed by Nix users.

pdf-tools

The pdf-tools package depends on the epdfinfo binary. If you opt to install the package via Nix (e.g. by adding emacsPackages.pdf-tools to your installed packages) you'll want to prevent Elpaca from installing the package. For example:

(use-package pdf-tools :elpaca nil)

Manually setting elpaca-core-date

Some collected notes following the discussion on issue #222.

I recently added dependency version constraint checks to Elpaca: 85bfd98

The core date is a YYYYMMDD format version for all of the bundled, or core, elisp shipped with Emacs. Elpaca is able to figure this out for stable releases and uses emacs-build-time when it is available (for people actively developing core packages). When users are not on a stable release and emacs-build-time is not set, the variable will need to be manually set.

If Emacs is installed via Nixpkgs, then emacs-build-time will be nil, and elpaca will complain. If you know the build time, you may manually set it; Make sure this is before the installer script since it needs to be set before elpaca.el is loaded.

Retrieving the date via file name

If you are installing emacs-git from the emacs-overlay, the store path name should include the date. You can evaluate (emacs-build-description) in a scratch buffer to see the build configuration that includes something like --prefix=/nix/store/...-emacs-git-20YYMMDD.

Some elisp to automate this, provided by mplanchard and progfolio:

(defun my/nixos-p ()
  "Return t if operating system is NixOS, nil otherwise."
  (string-match-p "NixOS" (shell-command-to-string "uname -v")))

(defun my/nixos/get-emacs-build-date ()
  "Return NixOS Emacs build date."
  (string-match "--prefix.*emacs.*\\([:digit:](/progfolio/elpaca/wiki/:digit:)\\{8\\}\\)" system-configuration-options)
  (string-to-number (match-string 1 system-configuration-options)))

;; Run this before the elpaca.el is loaded. Before the installer in your init.el is a good spot.
(when (my/nixos-p) (setq elpaca-core-date (list (my/nixos/get-emacs-build-date))))

Retrieving the date via Hydra

Alternatively, if you are using a package that doesn't list the date and was installed from a cache, you can check the build date from Hydra.

If you use the NixOS package search, then you can show more details for a package and follow the appropriate hydra link under "Platforms". If you are lucky, a list of the latest builds will be populated. The linked builds will have a "Details" tab where you can check the output store paths. These should match your local install, which you can check as above via emacs-build-description, or in a shell like realpath $(which emacs).

In my case, I'm using emacs29-pgtk on x86_64-darwin and the hydra link leads to any empty list with the notice:

This job is not a member of the latest evaluation of its jobset. This means it was removed or had an evaluation error.

To instead find the build info manually, search for emacs-pgtk-29.4 (the search queries were giving me trouble unless I used the name used in the store path). There happens to be no recent successful builds listed for my machine, but following one of the unsuccessful builds will have a date and link for the most recent successful build.

Example

As of writing this, the search query above has job #273471520 as the only result for x86_64-darwin.

Screen Shot 2024-09-23 at 19 44 54

At the bottom of the page for that build, I follow the link for the last successful build with job #271555178. Screen Shot 2024-09-23 at 19 45 35

As before, I check that the output store path under the successful job's "Details" tab matches my own.

Screen Shot 2024-09-23 at 19 46 15

Done!!

Final Notes

In the lucky outcome above where the hydra links under the package search are populated, they will be specific to whichever channel you're using. In the manual hydra search case I'm not sure how to easily distinguish between stable versus unstable channels (with the current search capabilities). I'm using the nixpkgs-unstable channel, so I didn't have to look very hard to find the matching build. Best of luck, I suppose!

I didn't receive any responses in the #nixos irc channel when asking if there was an easier way (on 2024-09-23), so if anyone has a cleaner solution, please share!