emacs-twist / twist.nix

Build an entire Emacs configuration as a Nix package in a pure, reproducible way
GNU General Public License v3.0
66 stars 6 forks source link

Support ELPA packages with :url nil #62

Closed terlar closed 1 year ago

terlar commented 1 year ago

OT So I'm finally getting around to explore this and doing my own take on using this and I'm avoiding emacsmirror. /OT

When I try to run the emacsTwist function on my configuration and I guess it tries to look up a package from the elpa inventory it fails when trying to find cycle-quotes. I checked the elpa-packages file and noticed ("cycle-quotes" :url nil) and I'm guessing that is the case why it is not found.

Reading at the top of this file I see:

;; For KIND :url URL is the URL of the remote git repository that we want
;; to track, or `nil' if there is no upstream, i.e., if development of this
;; package takes place directly on the `externals/<name>' branch of the
;; `elpa.git' repository.  For packages of KIND :core URL must be a list of:
;;    STRING = A file-name to copy from Emacs repo.
;;    (STRING STRING) = A file-name to copy renamed from Emacs repo.

I'm guessing :url nil, e.g. looking inside externals/<name> is not currently supported or do you have any other idea why it would fail finding this specific package?

akirak commented 1 year ago

Hello, thank you for trying out twist.

Twist provides two ways to build ELPA packages:

It is better to build packages from source whenever possible. An archive file can become unavailable when the package updates.

Unfortunately, quite a few packages on GNU ELPA seem to require manual intervention (I guess the GNU ELPA maintainers have a lot of private workarounds for those packages), so the latter process is suitable unless :auto-sync t is specified. An example configuration which builds your configuration has the following inventory entry which restricts source builds to auto-sync packages:

[
  # local packages

  # GNU elpa from source
  {
    name = "gnu";
    type = "elpa";
    path = inputs.gnu-elpa.outPath + "/elpa-packages";
    core-src = inputs.emacs.outPath;
    auto-sync-only = true;
    exclude = [
      "bbdb"
    ];
  }

  # melpa and non-gnu
  ...

  # GNU elpa from archive
  {
    type = "archive";
    url = "https://elpa.gnu.org/packages/";
  }

  # more
  ...

]

Regarding cycle-quotes, it is built from the archive. The above configuration should work.

For packages on Non-GNU ELPA, most packages can be built from source. See the inventory configuration in the example repository. It builds your configuration.

terlar commented 1 year ago

I did have this configuration and it didn't work:

emacsFromTwist = pkgs.emacsTwist {
  emacsPackage = pkgs.emacsPgtkNativeComp.overrideAttrs (_: {version = "29.0.50";});
  initFiles = [(pkgs.tangleOrgBabelFile "init.el" ./init.org {})];
  lockDir = ./lock;
  inventories = [
    {
      name = "custom";
      type = "melpa";
      path = ./recipes;
    }
    {
      name = "gnu";
      type = "elpa";
      path = gnu-elpa.outPath + "/elpa-packages";
      core-src = pkgs.emacsPgtkNativeComp.outPath;
      auto-sync-only = true;
    }
    {
      name = "melpa";
      type = "melpa";
      path = melpa.outPath + "/recipes";
    }
    {
      name = "nongnu";
      type = "elpa";
      path = nongnu-elpa.outPath + "/elpa-packages";
    }
    {
      name = "gnu-archive";
      type = "archive";
      url = "https://elpa.gnu.org/packages/";
    }
  ];
};

It seems to be due to the other repos that it would be working in your example?

The packages failing (all from ELPA):

~I have still not managed to build it also ran into API rate-limiting now, so have to wait a bit.~ Just managed after this comment. So had to remove all those mentioned ELPA packages or things depending on those.

Shouldn't these packages be fetched from the gnu-archive?

akirak commented 1 year ago

You can bypass the rate limiting of GitHub by adding a personal access token to ~/.config/nix/nix.conf.

akirak commented 1 year ago

Yes, those failing packages should be built from archives.

Did you run the following command before you build your config? Sorry for not having prepared a proper documentation.

nix run .#lock --impure
terlar commented 1 year ago

Hmm, that was the last missing piece. I could have sworn I tried to evaluate makeApps {lockDirName = "lock";} and it failed with the same error, so tried going down the path to fix all those errors first. But now when I ran nix run .#lock --impure it worked, also with those packages enabled again.

I will play around a bit more and let you know if I run into some other errors. I guess the archive ones are only working when you have a lock file right?

akirak commented 1 year ago

I guess the archive ones are only working when you have a lock file right?

Actually, the archive access depends on the mode of operation. I didn't come up with a better way than this in order to avoid access to remote servers in pure builds.

akirak commented 1 year ago

I assume you don't encounter this problem any more. Closing.