Skip to content

Commit 23e610d

Browse files
authored
emacs: support and enable __structuredAttrs in elisp build helpers (#387193)
2 parents a398296 + d64a233 commit 23e610d

File tree

6 files changed

+20
-18
lines changed

6 files changed

+20
-18
lines changed

nixos/doc/manual/release-notes/rl-2505.section.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@
204204

205205
- `pkgs.nextcloud28` has been removed since it's out of support upstream.
206206

207+
- Emacs lisp build helpers, such as `emacs.pkgs.melpaBuild`, now enables `__structuredAttrs` by default.
208+
Environment variables have to be passed via the `env` attribute.
209+
207210
- `buildGoModule` now passes environment variables via the `env` attribute. `CGO_ENABLED` should now be specified with `env.CGO_ENABLED` when passing to buildGoModule. Direct specification of `CGO_ENABLED` is now redirected by a compatibility layer with a warning, but will become an error in future releases.
208211

209212
Go-related environment variables previously shadowed by `buildGoModule` now results in errors when specified directly. Such variables include `GOOS` and `GOARCH`.

pkgs/applications/editors/emacs/build-support/elpa.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ lib.extendMkDerivation {
4343
4444
emacs --batch -Q -l "$elpa2nix" \
4545
-f elpa2nix-install-package \
46-
"$src" "$out/share/emacs/site-lisp/elpa"
46+
"$src" "$out/share/emacs/site-lisp/elpa" \
47+
${if finalAttrs.turnCompilationWarningToError then "t" else "nil"} \
48+
${if finalAttrs.ignoreCompilationError then "t" else "nil"}
4749
4850
runHook postInstall
4951
'';

pkgs/applications/editors/emacs/build-support/elpa2nix.el

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
(if (not noninteractive)
66
(error "`elpa2nix-install-package' is to be used only with -batch"))
77
(pcase command-line-args-left
8-
(`(,archive ,elpa)
9-
(progn (setq package-user-dir elpa)
8+
(`(,archive ,elpa ,turn-compilation-warning-to-error ,ignore-compilation-error)
9+
(progn (setq byte-compile-error-on-warn (string= turn-compilation-warning-to-error "t"))
10+
(setq byte-compile-debug (string= ignore-compilation-error "nil"))
11+
(setq package-user-dir elpa)
1012
(elpa2nix-install-file archive)))))
1113

1214
(defun elpa2nix-install-from-buffer ()
@@ -31,13 +33,3 @@ The file can either be a tar file or an Emacs Lisp file."
3133

3234
;; Allow installing package tarfiles larger than 10MB
3335
(setq large-file-warning-threshold nil)
34-
35-
(let ((flag (getenv "turnCompilationWarningToError")))
36-
(when (and flag
37-
;; we do not use `string-empty-p' because it requires subr-x in Emacs <= 26
38-
(not (string= flag "")))
39-
(setq byte-compile-error-on-warn t)))
40-
41-
(let ((flag (getenv "ignoreCompilationError")))
42-
(when (string= flag "")
43-
(setq byte-compile-debug t)))

pkgs/applications/editors/emacs/build-support/generic.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ lib.extendMkDerivation {
6161
propagatedUserEnvPkgs = finalAttrs.packageRequires ++ propagatedUserEnvPkgs;
6262

6363
strictDeps = args.strictDeps or true;
64+
__structuredAttrs = args.__structuredAttrs or true;
6465

6566
inherit turnCompilationWarningToError ignoreCompilationError;
6667

pkgs/applications/editors/emacs/build-support/melpa.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ lib.extendMkDerivation {
185185
emacs --batch -Q \
186186
-l "$elpa2nix" \
187187
-f elpa2nix-install-package \
188-
"$archive" "$out/share/emacs/site-lisp/elpa"
188+
"$archive" "$out/share/emacs/site-lisp/elpa" \
189+
${if finalAttrs.turnCompilationWarningToError then "t" else "nil"} \
190+
${if finalAttrs.ignoreCompilationError then "t" else "nil"}
189191
190192
runHook postInstall
191193
'';

pkgs/applications/editors/emacs/elisp-packages/melpa-packages.nix

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,10 @@ let
153153
# https://github.com/Golevka/emacs-clang-complete-async/issues/90
154154
auto-complete-clang-async = (addPackageRequires super.auto-complete-clang-async [ self.auto-complete ]).overrideAttrs (old: {
155155
buildInputs = old.buildInputs ++ [ pkgs.llvmPackages.llvm ];
156-
CFLAGS = "-I${lib.getLib pkgs.llvmPackages.libclang}/include";
157-
LDFLAGS = "-L${lib.getLib pkgs.llvmPackages.libclang}/lib";
156+
env = old.env or { } // {
157+
CFLAGS = "-I${lib.getLib pkgs.llvmPackages.libclang}/include";
158+
LDFLAGS = "-L${lib.getLib pkgs.llvmPackages.libclang}/lib";
159+
};
158160
});
159161

160162
# part of a larger package
@@ -242,7 +244,7 @@ let
242244
# - https://github.com/vedang/pdf-tools/issues/102
243245
# - https://github.com/vedang/pdf-tools/issues/103
244246
# - https://github.com/vedang/pdf-tools/issues/109
245-
CXXFLAGS = "-std=c++17";
247+
env = old.env or { } // { CXXFLAGS = "-std=c++17"; };
246248

247249
nativeBuildInputs = old.nativeBuildInputs ++ [
248250
pkgs.autoconf
@@ -294,7 +296,7 @@ let
294296

295297
irony = super.irony.overrideAttrs (old: {
296298
cmakeFlags = old.cmakeFlags or [ ] ++ [ "-DCMAKE_INSTALL_BINDIR=bin" ];
297-
env.NIX_CFLAGS_COMPILE = "-UCLANG_RESOURCE_DIR";
299+
env = old.env or { } // { NIX_CFLAGS_COMPILE = "-UCLANG_RESOURCE_DIR"; };
298300
preConfigure = ''
299301
pushd server
300302
'';

0 commit comments

Comments
 (0)