From ad3ddef70bd8cac28eccc8b5312d3bce15babcb8 Mon Sep 17 00:00:00 2001 From: Marien Zwart Date: Mon, 4 Mar 2024 19:19:51 +1100 Subject: [PATCH] Switch to melpaBuild for generated packages trivialBuild results in files installed directly into site-lisp/, without package metadata. This breaks ELPA packages whose dependencies we've replaced: package.el refuses to activate the ELPA package because as far as it knows its dependency is not installed. melpaBuild seems the easiest way of generating an activatable package that works with packages we leave untouched. --- package.nix | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/package.nix b/package.nix index e747344..f2c4e34 100644 --- a/package.nix +++ b/package.nix @@ -17,6 +17,7 @@ linkFarm, runCommand, runtimeShell, + writeText, }: let inherit (lib) optional optionalAttrs optionalString; @@ -110,18 +111,31 @@ let # building our own package. assert lib.assertMsg (!(p ? recipe.pre-build)) "${name}: pre-build not supported"; assert lib.assertMsg (!(p ? recipe.build)) "${name}: build not supported"; - # epkgs.trivialBuild takes an attrset, it does not support + # epkgs.*Build helpers take an attrset, they do not support # mkDerivation's fixed-point evaluation (`finalAttrs`). - # If it did, the buildInputs calculation should use it. - esuper.trivialBuild ({ + # If they did, the buildInputs stuff should use finalAttrs.src. + + # This uses melpaBuild instead of trivialBuild to end up with + # 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 ({ pname = name; - # src gets added below. - # version is required, but some other packages in nixpkgs just set 1. - version = "1"; + # Nix requires that we set version. Inherit it from the + # original if available: package.el currently does not check + # versions of dependencies but there's a fixme for that in the + # code... + version = origEPkg.version or "1"; + # melpa2nix requires we set this. + commit = p.pin; meta = { description = "trivial build for doom-emacs"; }; - buildInputs = map (name: eself.${name}) reqlist; + # Just enough to make melpa2nix work. + # TODO: pass "files" through, drop postUnpack hack below? + recipe = writeText "generated-recipe" + "(${name} :fetcher github :repo \"marienz/made-up\")"; + buildInputs = (map (name: eself.${name}) reqlist); } // optionalAttrs (p ? recipe.files && p.recipe.files != { defaults = "*"; }) { # HACK: files can contain :defaults, which splices in defaults. # If files starts with :defaults, the entire thing gets