build-support/emacs: refactor
- Remove superflous `let` with `defaultMeta` These can just be assigned to meta directly instead. - Hoist internal intermediate derivation - Remove top-level `with lib` - Inherit `lib`/`builtins` into scopes
This commit is contained in:
parent
05d50dc97a
commit
3618d1d247
4 changed files with 70 additions and 73 deletions
|
@ -2,7 +2,11 @@
|
|||
|
||||
{ lib, stdenv, emacs, texinfo, writeText, gcc }:
|
||||
|
||||
with lib;
|
||||
let
|
||||
handledArgs = [ "files" "fileSpecs" "meta" ];
|
||||
genericBuild = import ./generic.nix { inherit lib stdenv emacs texinfo writeText gcc; };
|
||||
|
||||
in
|
||||
|
||||
{ pname
|
||||
, version
|
||||
|
@ -11,15 +15,7 @@ with lib;
|
|||
, ...
|
||||
}@args:
|
||||
|
||||
let
|
||||
|
||||
defaultMeta = {
|
||||
homepage = args.src.meta.homepage or "https://elpa.gnu.org/packages/${pname}.html";
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
import ./generic.nix { inherit lib stdenv emacs texinfo writeText gcc; } ({
|
||||
genericBuild ({
|
||||
|
||||
dontUnpack = true;
|
||||
|
||||
|
@ -33,9 +29,9 @@ import ./generic.nix { inherit lib stdenv emacs texinfo writeText gcc; } ({
|
|||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = defaultMeta // meta;
|
||||
meta = {
|
||||
homepage = args.src.meta.homepage or "https://elpa.gnu.org/packages/${pname}.html";
|
||||
} // meta;
|
||||
}
|
||||
|
||||
// removeAttrs args [ "files" "fileSpecs"
|
||||
"meta"
|
||||
])
|
||||
// removeAttrs args handledArgs)
|
||||
|
|
|
@ -2,6 +2,26 @@
|
|||
|
||||
{ lib, stdenv, emacs, texinfo, writeText, gcc, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) optionalAttrs getLib;
|
||||
handledArgs = [ "buildInputs" "packageRequires" "meta" ];
|
||||
|
||||
setupHook = writeText "setup-hook.sh" ''
|
||||
source ${./emacs-funcs.sh}
|
||||
|
||||
if [[ ! -v emacsHookDone ]]; then
|
||||
emacsHookDone=1
|
||||
|
||||
# If this is for a wrapper derivation, emacs and the dependencies are all
|
||||
# run-time dependencies. If this is for precompiling packages into bytecode,
|
||||
# emacs is a compile-time dependency of the package.
|
||||
addEnvHooks "$hostOffset" addEmacsVars
|
||||
addEnvHooks "$targetOffset" addEmacsVars
|
||||
fi
|
||||
'';
|
||||
|
||||
in
|
||||
|
||||
{ pname
|
||||
, version
|
||||
, buildInputs ? []
|
||||
|
@ -10,15 +30,6 @@
|
|||
, ...
|
||||
}@args:
|
||||
|
||||
let
|
||||
defaultMeta = {
|
||||
broken = false;
|
||||
platforms = emacs.meta.platforms;
|
||||
} // lib.optionalAttrs ((args.src.meta.homepage or "") != "") {
|
||||
homepage = args.src.meta.homepage;
|
||||
};
|
||||
in
|
||||
|
||||
stdenv.mkDerivation (finalAttrs: ({
|
||||
name = "emacs-${pname}-${finalAttrs.version}";
|
||||
|
||||
|
@ -42,28 +53,21 @@ stdenv.mkDerivation (finalAttrs: ({
|
|||
propagatedBuildInputs = packageRequires;
|
||||
propagatedUserEnvPkgs = packageRequires;
|
||||
|
||||
setupHook = writeText "setup-hook.sh" ''
|
||||
source ${./emacs-funcs.sh}
|
||||
|
||||
if [[ ! -v emacsHookDone ]]; then
|
||||
emacsHookDone=1
|
||||
|
||||
# If this is for a wrapper derivation, emacs and the dependencies are all
|
||||
# run-time dependencies. If this is for precompiling packages into bytecode,
|
||||
# emacs is a compile-time dependency of the package.
|
||||
addEnvHooks "$hostOffset" addEmacsVars
|
||||
addEnvHooks "$targetOffset" addEmacsVars
|
||||
fi
|
||||
'';
|
||||
inherit setupHook;
|
||||
|
||||
doCheck = false;
|
||||
|
||||
meta = defaultMeta // meta;
|
||||
meta = {
|
||||
broken = false;
|
||||
platforms = emacs.meta.platforms;
|
||||
} // optionalAttrs ((args.src.meta.homepage or "") != "") {
|
||||
homepage = args.src.meta.homepage;
|
||||
} // meta;
|
||||
}
|
||||
|
||||
// lib.optionalAttrs (emacs.withNativeCompilation or false) {
|
||||
// optionalAttrs (emacs.withNativeCompilation or false) {
|
||||
|
||||
LIBRARY_PATH = "${lib.getLib stdenv.cc.libc}/lib";
|
||||
LIBRARY_PATH = "${getLib stdenv.cc.libc}/lib";
|
||||
|
||||
nativeBuildInputs = [ gcc ];
|
||||
|
||||
|
@ -83,4 +87,4 @@ stdenv.mkDerivation (finalAttrs: ({
|
|||
'';
|
||||
}
|
||||
|
||||
// removeAttrs args [ "buildInputs" "packageRequires" "meta" ]))
|
||||
// removeAttrs args handledArgs))
|
||||
|
|
|
@ -3,37 +3,8 @@
|
|||
|
||||
{ lib, stdenv, fetchFromGitHub, emacs, texinfo, writeText, gcc }:
|
||||
|
||||
with lib;
|
||||
|
||||
{ /*
|
||||
pname: Nix package name without special symbols and without version or
|
||||
"emacs-" prefix.
|
||||
*/
|
||||
pname
|
||||
/*
|
||||
ename: Original Emacs package name, possibly containing special symbols.
|
||||
*/
|
||||
, ename ? null
|
||||
, version
|
||||
, recipe
|
||||
, meta ? {}
|
||||
, ...
|
||||
}@args:
|
||||
|
||||
let
|
||||
|
||||
defaultMeta = {
|
||||
homepage = args.src.meta.homepage or "https://melpa.org/#/${pname}";
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
import ./generic.nix { inherit lib stdenv emacs texinfo writeText gcc; } ({
|
||||
|
||||
ename =
|
||||
if ename == null
|
||||
then pname
|
||||
else ename;
|
||||
genericBuild = import ./generic.nix { inherit lib stdenv emacs texinfo writeText gcc; };
|
||||
|
||||
packageBuild = stdenv.mkDerivation {
|
||||
name = "package-build";
|
||||
|
@ -55,9 +26,35 @@ import ./generic.nix { inherit lib stdenv emacs texinfo writeText gcc; } ({
|
|||
";
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
{ /*
|
||||
pname: Nix package name without special symbols and without version or
|
||||
"emacs-" prefix.
|
||||
*/
|
||||
pname
|
||||
/*
|
||||
ename: Original Emacs package name, possibly containing special symbols.
|
||||
*/
|
||||
, ename ? null
|
||||
, version
|
||||
, recipe
|
||||
, meta ? {}
|
||||
, ...
|
||||
}@args:
|
||||
|
||||
genericBuild ({
|
||||
|
||||
ename =
|
||||
if ename == null
|
||||
then pname
|
||||
else ename;
|
||||
|
||||
elpa2nix = ./elpa2nix.el;
|
||||
melpa2nix = ./melpa2nix.el;
|
||||
|
||||
inherit packageBuild;
|
||||
|
||||
preUnpack = ''
|
||||
mkdir -p "$NIX_BUILD_TOP/recipes"
|
||||
if [ -n "$recipe" ]; then
|
||||
|
@ -104,7 +101,9 @@ import ./generic.nix { inherit lib stdenv emacs texinfo writeText gcc; } ({
|
|||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = defaultMeta // meta;
|
||||
meta = {
|
||||
homepage = args.src.meta.homepage or "https://melpa.org/#/${pname}";
|
||||
} // meta;
|
||||
}
|
||||
|
||||
// removeAttrs args [ "meta" ])
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
{ callPackage, lib, ... }@envargs:
|
||||
|
||||
with lib;
|
||||
|
||||
args:
|
||||
|
||||
callPackage ./generic.nix envargs ({
|
||||
|
|
Loading…
Reference in a new issue