Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emacs: fix default values of withFoo flags after overrideAttrs #365784

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from

Conversation

jian-lin
Copy link
Contributor

Previously, the normal way to override src and version led to wrong default values of withFoo flags.

Here is an minimal reproducible example for withXwidgets which should default to false when version >= 30.

$ nix eval --include nixpkgs=$PWD --impure --expr '
let pkgs = import <nixpkgs> { config = { }; overlays = [ ]; };
in (pkgs.emacs29-pgtk.overrideAttrs { version = "30"; }).withXwidgets
'
true

This fix keeps backward compatibility for the .override interface.

Fixes: nix-community/emacs-overlay#455

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.

Previously, the normal way to override src and version led to wrong
default values of withFoo flags.

Here is an minimal reproducible example for withXwidgets which should
default to false when version >= 30.

```console
$ nix eval --include nixpkgs=$PWD --impure --expr '
let pkgs = import <nixpkgs> { config = { }; overlays = [ ]; };
in (pkgs.emacs29-pgtk.overrideAttrs { version = "30"; }).withXwidgets
'
true
```

This fix keeps backward compatibility for the .override interface.

Fixes: nix-community/emacs-overlay#455
withGlibNetworking ? withPgtk || withGTK3 || (withX && withXwidgets),
withGpm ? stdenv.hostPlatform.isLinux,
withImageMagick ? lib.versionOlder version "27" && (withX || withNS),
withNativeCompilation ? throw "dummy value for backward compatibility, should never be evaled",
Copy link
Contributor Author

@jian-lin jian-lin Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably we need a better way to handle this.

The indention of keeping this optional flags is to keep backward compatibility for the .override interface: emacs29-pgtk.override { withXwidgets = false; }.

Comment on lines +544 to +558
assertions =
assert
(finalAttrs.withGTK3 && !finalAttrs.withNS && variant != "macport")
-> finalAttrs.withX || finalAttrs.withPgtk;
assert
finalAttrs.noGui
-> !(finalAttrs.withX || finalAttrs.withGTK3 || finalAttrs.withNS || variant == "macport");
assert finalAttrs.withAcl -> stdenv.hostPlatform.isLinux;
assert finalAttrs.withAlsaLib -> stdenv.hostPlatform.isLinux;
assert finalAttrs.withGpm -> stdenv.hostPlatform.isLinux;
assert
finalAttrs.withNS -> stdenv.hostPlatform.isDarwin && !(finalAttrs.withX || variant == "macport");
assert finalAttrs.withPgtk -> finalAttrs.withGTK3 && !finalAttrs.withX;
assert finalAttrs.withXwidgets -> !finalAttrs.noGui && (finalAttrs.withGTK3 || finalAttrs.withPgtk);
true; # dummy value to make syntax right
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works but maybe we can improve it.

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

Successfully merging this pull request may close these issues.

1 participant