Skip to content

Commit

Permalink
emacs: make melpaBuild accept recipe content as a string (#334955)
Browse files Browse the repository at this point in the history
  • Loading branch information
jian-lin authored Aug 28, 2024
2 parents e71b171 + 5be4ecc commit 63bec82
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions pkgs/applications/editors/emacs/build-support/melpa.nix
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@ libBuildHelper.extendMkDerivation' genericBuild (finalAttrs:
/*
recipe: Optional MELPA recipe.
Default: a minimally functional recipe
This can be a path of a recipe file, a string of the recipe content or an empty string.
The default value is used if it is an empty string.
*/
, recipe ? (writeText "${finalAttrs.pname}-recipe" ''
(${finalAttrs.ename} :fetcher git :url ""
${lib.optionalString (finalAttrs.files != null) ":files ${finalAttrs.files}"})
'')
, recipe ? ""
, preUnpack ? ""
, postUnpack ? ""
, meta ? {}
Expand Down Expand Up @@ -98,9 +97,21 @@ libBuildHelper.extendMkDerivation' genericBuild (finalAttrs:

preUnpack = ''
mkdir -p "$NIX_BUILD_TOP/recipes"
if [ -n "$recipe" ]; then
cp "$recipe" "$NIX_BUILD_TOP/recipes/$ename"
recipeFile="$NIX_BUILD_TOP/recipes/$ename"
if [ -r "$recipe" ]; then
ln -s "$recipe" "$recipeFile"
nixInfoLog "link recipe"
elif [ -n "$recipe" ]; then
printf "%s" "$recipe" > "$recipeFile"
nixInfoLog "write recipe"
else
cat > "$recipeFile" <<'EOF'
(${finalAttrs.ename} :fetcher git :url "" ${lib.optionalString (finalAttrs.files != null) ":files ${finalAttrs.files}"})
EOF
nixInfoLog "use default recipe"
fi
nixInfoLog "recipe content:" "$(< $recipeFile)"
unset -v recipeFile
ln -s "$packageBuild" "$NIX_BUILD_TOP/package-build"
Expand Down

0 comments on commit 63bec82

Please sign in to comment.