From 2a436566e8bd515895d8572afd27328a42bccd85 Mon Sep 17 00:00:00 2001 From: Marien Zwart Date: Sun, 16 Jun 2024 23:34:53 +1000 Subject: [PATCH] Force a dependency on generated dependencies json This otherwise gets garbage-collected and then has to be regenerated on next flake evaluation. It may not be that slow to regenerate, but it's also tiny enough we may as well keep it alive. --- README.md | 5 ----- default.nix | 12 ++++++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index fdaa92a..f145676 100644 --- a/README.md +++ b/README.md @@ -401,11 +401,6 @@ There are a few issues: determine packages to install and to determine package dependencies for packages not in emacs-overlay. Especially the latter is slow. - - The dependency data probably gets garbage-collected, making subsequent - evaluation slow even if nothing changed. I intend to make the installed - packages depend on this data to work around this, but I have not implemented - it yet. - - Doom (currently) [does not native-compile ahead of time](https://github.com/doomemacs/doomemacs/issues/6811), but Unstraightened (or nixpkgs, really), does. diff --git a/default.nix b/default.nix index 305c688..168e048 100644 --- a/default.nix +++ b/default.nix @@ -204,7 +204,7 @@ let # something package.el understands as satisfying dependencies. # This is necessary if we're replacing a pinned ELPA dependency # of an unpinned ELPA package. - esuper.melpaBuild { + (esuper.melpaBuild { pname = name; # melpaBuild requires we set `version` and `commit` here # (leaving `version` unset until overrideAttrs below does not @@ -221,7 +221,15 @@ let # TODO: refactor out the recursive call to makePackage. # (Currently needed for dependencies on packages not in epkgs or doom.) packageRequires = map (name: eself.${name} or (makePackage name {})) reqlist; - }); + }).overrideAttrs (prev: { + # We only depend on this during evaluation. Force a dependency so it does not + # get garbage-collected, which slows down subsequent evaluation. + inherit reqfile; + postInstall = (prev.postInstall or "") + '' + mkdir -p $out/nix-support + ln -s $reqfile $out/nix-support/unstraightened-dependencies.json + ''; + })); url = if (p.recipe.host or "") == "github" && p ? recipe.repo then "https://github.com/${p.recipe.repo}"