From 4b1c49fedec451dd9d94f3692191e5df45147a84 Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Wed, 5 Mar 2025 10:08:16 +0800 Subject: [PATCH 1/4] emacs.pkgs.irony: respect old.env in overrideAttrs --- .../editors/emacs/elisp-packages/melpa-packages.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/editors/emacs/elisp-packages/melpa-packages.nix b/pkgs/applications/editors/emacs/elisp-packages/melpa-packages.nix index 2ed31090e106..1108d0e154b6 100644 --- a/pkgs/applications/editors/emacs/elisp-packages/melpa-packages.nix +++ b/pkgs/applications/editors/emacs/elisp-packages/melpa-packages.nix @@ -294,7 +294,7 @@ let irony = super.irony.overrideAttrs (old: { cmakeFlags = old.cmakeFlags or [ ] ++ [ "-DCMAKE_INSTALL_BINDIR=bin" ]; - env.NIX_CFLAGS_COMPILE = "-UCLANG_RESOURCE_DIR"; + env = old.env or { } // { NIX_CFLAGS_COMPILE = "-UCLANG_RESOURCE_DIR"; }; preConfigure = '' pushd server ''; From c6fef5561623762dcb8e6d3063a6871225bc592e Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Wed, 5 Mar 2025 10:10:35 +0800 Subject: [PATCH 2/4] emacs.pkgs.{pdf-tools,auto-complete-clang-async}: use env attr This is compatible with __structuredAttrs. --- .../editors/emacs/elisp-packages/melpa-packages.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/editors/emacs/elisp-packages/melpa-packages.nix b/pkgs/applications/editors/emacs/elisp-packages/melpa-packages.nix index 1108d0e154b6..40a6f2f7aec3 100644 --- a/pkgs/applications/editors/emacs/elisp-packages/melpa-packages.nix +++ b/pkgs/applications/editors/emacs/elisp-packages/melpa-packages.nix @@ -153,8 +153,10 @@ let # https://github.com/Golevka/emacs-clang-complete-async/issues/90 auto-complete-clang-async = (addPackageRequires super.auto-complete-clang-async [ self.auto-complete ]).overrideAttrs (old: { buildInputs = old.buildInputs ++ [ pkgs.llvmPackages.llvm ]; - CFLAGS = "-I${lib.getLib pkgs.llvmPackages.libclang}/include"; - LDFLAGS = "-L${lib.getLib pkgs.llvmPackages.libclang}/lib"; + env = old.env or { } // { + CFLAGS = "-I${lib.getLib pkgs.llvmPackages.libclang}/include"; + LDFLAGS = "-L${lib.getLib pkgs.llvmPackages.libclang}/lib"; + }; }); # part of a larger package @@ -242,7 +244,7 @@ let # - https://github.com/vedang/pdf-tools/issues/102 # - https://github.com/vedang/pdf-tools/issues/103 # - https://github.com/vedang/pdf-tools/issues/109 - CXXFLAGS = "-std=c++17"; + env = old.env or { } // { CXXFLAGS = "-std=c++17"; }; nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.autoconf From f698c4dd154885c1edf953de65ca44edda253ea8 Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Wed, 5 Mar 2025 10:02:55 +0800 Subject: [PATCH 3/4] emacs: support __structuredAttrs in elisp build helpers --- .../editors/emacs/build-support/elpa.nix | 4 +++- .../editors/emacs/build-support/elpa2nix.el | 16 ++++------------ .../editors/emacs/build-support/melpa.nix | 4 +++- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/pkgs/applications/editors/emacs/build-support/elpa.nix b/pkgs/applications/editors/emacs/build-support/elpa.nix index fcaef43953ef..50abadccf9d9 100644 --- a/pkgs/applications/editors/emacs/build-support/elpa.nix +++ b/pkgs/applications/editors/emacs/build-support/elpa.nix @@ -43,7 +43,9 @@ lib.extendMkDerivation { emacs --batch -Q -l "$elpa2nix" \ -f elpa2nix-install-package \ - "$src" "$out/share/emacs/site-lisp/elpa" + "$src" "$out/share/emacs/site-lisp/elpa" \ + ${if finalAttrs.turnCompilationWarningToError then "t" else "nil"} \ + ${if finalAttrs.ignoreCompilationError then "t" else "nil"} runHook postInstall ''; diff --git a/pkgs/applications/editors/emacs/build-support/elpa2nix.el b/pkgs/applications/editors/emacs/build-support/elpa2nix.el index 97cf2fd58a06..5b363b7b6640 100644 --- a/pkgs/applications/editors/emacs/build-support/elpa2nix.el +++ b/pkgs/applications/editors/emacs/build-support/elpa2nix.el @@ -5,8 +5,10 @@ (if (not noninteractive) (error "`elpa2nix-install-package' is to be used only with -batch")) (pcase command-line-args-left - (`(,archive ,elpa) - (progn (setq package-user-dir elpa) + (`(,archive ,elpa ,turn-compilation-warning-to-error ,ignore-compilation-error) + (progn (setq byte-compile-error-on-warn (string= turn-compilation-warning-to-error "t")) + (setq byte-compile-debug (string= ignore-compilation-error "nil")) + (setq package-user-dir elpa) (elpa2nix-install-file archive))))) (defun elpa2nix-install-from-buffer () @@ -31,13 +33,3 @@ The file can either be a tar file or an Emacs Lisp file." ;; Allow installing package tarfiles larger than 10MB (setq large-file-warning-threshold nil) - -(let ((flag (getenv "turnCompilationWarningToError"))) - (when (and flag - ;; we do not use `string-empty-p' because it requires subr-x in Emacs <= 26 - (not (string= flag ""))) - (setq byte-compile-error-on-warn t))) - -(let ((flag (getenv "ignoreCompilationError"))) - (when (string= flag "") - (setq byte-compile-debug t))) diff --git a/pkgs/applications/editors/emacs/build-support/melpa.nix b/pkgs/applications/editors/emacs/build-support/melpa.nix index bdca913e865d..876cf9a46ddc 100644 --- a/pkgs/applications/editors/emacs/build-support/melpa.nix +++ b/pkgs/applications/editors/emacs/build-support/melpa.nix @@ -185,7 +185,9 @@ lib.extendMkDerivation { emacs --batch -Q \ -l "$elpa2nix" \ -f elpa2nix-install-package \ - "$archive" "$out/share/emacs/site-lisp/elpa" + "$archive" "$out/share/emacs/site-lisp/elpa" \ + ${if finalAttrs.turnCompilationWarningToError then "t" else "nil"} \ + ${if finalAttrs.ignoreCompilationError then "t" else "nil"} runHook postInstall ''; From d64a233e4cfbffffab25b05bfa51487e718be260 Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Wed, 5 Mar 2025 10:05:37 +0800 Subject: [PATCH 4/4] emacs: enable __structuredAttrs by default in elisp build helpers --- nixos/doc/manual/release-notes/rl-2505.section.md | 3 +++ pkgs/applications/editors/emacs/build-support/generic.nix | 1 + 2 files changed, 4 insertions(+) diff --git a/nixos/doc/manual/release-notes/rl-2505.section.md b/nixos/doc/manual/release-notes/rl-2505.section.md index 1140e9b5ddff..389998f4a272 100644 --- a/nixos/doc/manual/release-notes/rl-2505.section.md +++ b/nixos/doc/manual/release-notes/rl-2505.section.md @@ -198,6 +198,9 @@ - `pkgs.nextcloud28` has been removed since it's out of support upstream. +- Emacs lisp build helpers, such as `emacs.pkgs.melpaBuild`, now enables `__structuredAttrs` by default. + Environment variables have to be passed via the `env` attribute. + - `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. Go-related environment variables previously shadowed by `buildGoModule` now results in errors when specified directly. Such variables include `GOOS` and `GOARCH`. diff --git a/pkgs/applications/editors/emacs/build-support/generic.nix b/pkgs/applications/editors/emacs/build-support/generic.nix index ddab4bc70a00..b4e96f6490fb 100644 --- a/pkgs/applications/editors/emacs/build-support/generic.nix +++ b/pkgs/applications/editors/emacs/build-support/generic.nix @@ -61,6 +61,7 @@ lib.extendMkDerivation { propagatedUserEnvPkgs = finalAttrs.packageRequires ++ propagatedUserEnvPkgs; strictDeps = args.strictDeps or true; + __structuredAttrs = args.__structuredAttrs or true; inherit turnCompilationWarningToError ignoreCompilationError;