emacs: add two parameters to genericBuild to control errors
This patch introduces two parameters, turnCompilationWarningToError and ignoreCompilationError, to control errors in genericBuild, which makes "nix build" be able to fail at elisp native compilation errors or warnings. This feature can be used in CI to improve code quality. Note that this patch keeps the old behavior by default. Hopefully one day we can flip the default value of ignoreCompilationError to false when enough packages are fixed. Also note that these two parameters can be changed per package using the overrideAttrs interface.
This commit is contained in:
@@ -27,6 +27,8 @@ in
|
||||
, buildInputs ? []
|
||||
, packageRequires ? []
|
||||
, meta ? {}
|
||||
, turnCompilationWarningToError ? false
|
||||
, ignoreCompilationError ? true
|
||||
, ...
|
||||
}@args:
|
||||
|
||||
@@ -73,6 +75,8 @@ stdenv.mkDerivation (finalAttrs: ({
|
||||
|
||||
addEmacsNativeLoadPath = true;
|
||||
|
||||
inherit turnCompilationWarningToError ignoreCompilationError;
|
||||
|
||||
postInstall = ''
|
||||
# Besides adding the output directory to the native load path, make sure
|
||||
# the current package's elisp files are in the load path, otherwise
|
||||
@@ -86,8 +90,9 @@ stdenv.mkDerivation (finalAttrs: ({
|
||||
"emacs \
|
||||
--batch \
|
||||
--eval '(setq large-file-warning-threshold nil)' \
|
||||
--eval '(setq byte-compile-error-on-warn ${if finalAttrs.turnCompilationWarningToError then "t" else "nil"})' \
|
||||
-f batch-native-compile {} \
|
||||
|| true"
|
||||
|| exit ${if finalAttrs.ignoreCompilationError then "0" else "\\$?"}"
|
||||
'';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user