Skip to content

emacs: support and enable __structuredAttrs in elisp build helpers#387193

Merged
jian-lin merged 4 commits intoNixOS:masterfrom
linj-fork:pr/elisp-enable-__structuredAttrs
Mar 8, 2025
Merged

emacs: support and enable __structuredAttrs in elisp build helpers#387193
jian-lin merged 4 commits intoNixOS:masterfrom
linj-fork:pr/elisp-enable-__structuredAttrs

Conversation

@jian-lin
Copy link
Contributor

@jian-lin jian-lin commented Mar 5, 2025

A step towards #205690.

This PR does not cause new elisp build failures.

FYI, this is the motivation of __structuredAttrs.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog This PR adds or changes release notes 6.topic: emacs Text editor 8.has: documentation This PR adds or changes documentation labels Mar 5, 2025
@github-actions github-actions bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Mar 5, 2025
@jian-lin jian-lin merged commit 23e610d into NixOS:master Mar 8, 2025
35 checks passed
@jian-lin jian-lin deleted the pr/elisp-enable-__structuredAttrs branch March 8, 2025 09:09
@ngn999
Copy link

ngn999 commented Mar 10, 2025

After a recent update(nix flake update), my Emacs configuration is failing to load. I'm getting errors indicating missing dependencies for several packages:

Loading /nix/store/7ad3rrwnr9m9z6gbr2c9nakq7yqks4gc-emacs-30.1/share/emacs/site-lisp/site-start (native compiled elisp)...done
Unable to activate package ‘solidity-flycheck’.
Required package ‘flycheck-32snapshot’ is unavailable
Unable to activate package ‘alert’.
Required package ‘gntp-0.1’ is unavailable
Unable to activate package ‘pomidor’.
Required package ‘alert-1.2’ is unavailable
Unable to activate package ‘alert’.
Required package ‘gntp-0.1’ is unavailable
Unable to activate package ‘org-pomodoro’.
Required package ‘alert-0.5.10’ is unavailable
Unable to activate package ‘magit-todos’.
Required package ‘f-0.17.2’ is unavailable
Unable to activate package ‘magit’.
Required package ‘llama-0.6.1’ is unavailable
Unable to activate package ‘alert’.
Required package ‘gntp-0.1’ is unavailable

In the latest nixpkgs-unstable, use-package in Emacs-overlay ignore all dependcies?

My configuration:

              emacsPkg = pkgs.emacsWithPackagesFromUsePackage {
                config = ./emacs/init.el;
                defaultInitFile = true;
                package = pkgs.emacs-unstable.override {
                  withNativeCompilation = false;
                };
                alwaysEnsure = false;
                alwaysTangle = true;
                extraEmacsPackages =
                  epkgs: with epkgs; [
                    treesit-grammars.with-all-grammars
                  ];
              };
;; Magit additional configurations
(use-package magit
  :ensure t
  :bind (:map magit-status-mode-map
              ("C-M-<up>" . magit-section-up))
  :config
  (when *is-a-mac*
    (add-hook 'magit-mode-hook (lambda () (local-unset-key [(meta h)])))))

Those errors was gone after I pin nixpkgs to a398296

@jian-lin
Copy link
Contributor Author

Could you provide a minimal reproducing example (in a new issue, ideally)? I do not see your ./emacs/init.el. Is withNativeCompilation = false; necessary?

@ngn999
Copy link

ngn999 commented Mar 10, 2025

withNativeCompilation = false; is not necessary.

OK, I understand. I'll add an example later.

@ngn999
Copy link

ngn999 commented Mar 10, 2025

  1. Install eamcs-overlay: https://github.com/nix-community/emacs-overlay
  2. Configure Emacs in flake.nix
environment.systemPackages = [
  (
    pkgs.emacsWithPackagesFromUsePackage {
      config = ./emacs/init.el;
      defaultInitFile = true;
      alwaysEnsure = false;
      alwaysTangle = true;
      extraEmacsPackages =
	epkgs: with epkgs; [
          treesit-grammars.with-all-grammars
	];
    };
  )
];
  1. ./emacs/init.el
(use-package magit
  :ensure t
  :config
  (setq-default magit-diff-refine-hunk 'all)

Edit: The Emacs package itself doesn't seem to be the issue. This error occurs with pkgs.emacs, pkgs.emacs-unstable, and pkgs.emacs-git.

@jian-lin
Copy link
Contributor Author

emacs-overlay and nixpkgs commit hash?

@ngn999
Copy link

ngn999 commented Mar 10, 2025

nixpkgs: 2d9e445
Emacs-overlay: 6a25d3f956603e1f18499f33951ad6f2a9fa2f6e

@jian-lin
Copy link
Contributor Author

@ngn999 It is caused by a stdenv bug and here is my fix PR. Since that fix PR needs to go through a staging cycle which takes a few weeks, I will revert d64a233 for now.

@jian-lin
Copy link
Contributor Author

Thanks for the report.

@kurnevsky
Copy link
Member

kurnevsky commented Mar 25, 2025

Hi. Any idea how a dependency can be added to an emacs package after this change? I used to have:

package.overrideAttrs (old: {
  packageRequires = old.packageRequires ++ [ d ];
  propagatedBuildInputs = old.propagatedBuildInputs ++ [ d ];
  propagatedUserEnvPkgs = old.propagatedUserEnvPkgs ++ [ d ];
})

But now it doesn't work. If I got it right propagatedUserEnvPkgs isn't properly updated as I can't see propagated-user-env-packages in the package output at all.

@jian-lin
Copy link
Contributor Author

@kurnevsky See my comments in #388829

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: emacs Text editor 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants