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

notmuch: extract optional dependencies #84008

Merged
merged 1 commit into from Apr 3, 2020
Merged

Conversation

mredaelli
Copy link
Contributor

@mredaelli mredaelli commented Apr 1, 2020

Motivation for this change

I realized today that installing neomutt installs notmuch which installs emacs which to me, using neovim, seems a bit wasteful :)

I extracted the optional dependencies and put them behind a few package options. Using this as an overlay on my system works, but would be happy to discuss everything, from formatting to defaults of the optional parameters to testing/touching other derivations depending on this one, ...

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@puckipedia
Copy link
Contributor

I believe the standard way of doing optional dependencies is to make them optional in the attrs (so ? null). For with-docs i think using withDocs would be more canonical?

@mredaelli
Copy link
Contributor Author

I believe the standard way of doing optional dependencies is to make them optional in the attrs (so ? null).

I can do that for ruby, but emacs for some reason, AFAIK, is needed for the tests, even if you skip the emacs tests and even if it's compiled without emacs, so we can't make it null.

Do you see a way around that?

For with-docs i think using withDocs would be more canonical?

Absolutely. Will fix that.

@@ -7,6 +7,8 @@
, emacs
, ruby
, which, dtach, openssl, bash, gdb, man
, withDocs ? true
Copy link
Member

Choose a reason for hiding this comment

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

How about having a different output for docs instead of disabling it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm afraid I don't know what that means/how to do it ^_^

Copy link
Member

Choose a reason for hiding this comment

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

You basically add:

outputs = [ "out" "doc" ];

Than it should move "$out/usr/share/doc" to "$doc" instead of "$out".
Having multiple outputs is a feature of nixpkgs and described in the nixpkgs manual here: https://nixos.org/nixpkgs/manual/#chap-multiple-output

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Something like this?

configureFlags = [ "--zshcompletiondir=${placeholder "out"}/share/zsh/site-functions" ];
configureFlags = [
"--zshcompletiondir=${placeholder "out"}/share/zsh/site-functions"
"--mandir=${placeholder "doc"}"
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this should go to man output. Some people want to read the manpage without reading the developer documentation. Also the man output automatically picks up the right files without an need for having to specify its path in configureFlags.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I noticed right after pushing. Fixing it now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There

bash-completion # (optional) dependency to install bash completion
emacs # (optional) to byte compile emacs code, also needed for tests
ruby # (optional) ruby bindings
bash-completion # (optional) dependency to install bash completion
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this invoked during build, or made a runtime reference? If the former is the case, it'd need to be in nativeBuildInputs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm likely build only. Let me try

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems to work. I updated the PR

Copy link
Contributor

Choose a reason for hiding this comment

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

Meh, I quickly tried by cross-compiling neomutt to aarch64, but this failed, as talloc required for notmuch currently fails to cross-compile.

I assume this is fine, we can always fix it up later.

@ofborg ofborg bot requested a review from flokli April 3, 2020 14:48
@flokli flokli merged commit ed3ec0b into NixOS:master Apr 3, 2020
@flokli
Copy link
Contributor

flokli commented Apr 3, 2020

Thanks!

@xaverdh
Copy link
Contributor

xaverdh commented Apr 4, 2020

Just out of curiosity: In the original derivation, does emacs end up in the runtime closure just due to the substituteInPlace part? Then I guess this could be solved by putting notmuch-emacs-mua into a different output (assuming that nix tracks runtime dependencies per output)?

@mredaelli
Copy link
Contributor Author

AFAIK, it happened because emacs was in the buildInputs

@flokli
Copy link
Contributor

flokli commented Apr 4, 2020

Nix tracks runtime closures, and does that per output. Even if you'd add libreoffice to buildInputs, if there's no reference in the "binary output", it wouldn't be downloaded if you'd donwload it from the cache (it however would be downloaded if you want to build it by yourself).

For this specific package, there's a single reference to emacs in the $out output:

nix why-depends -a /nix/store/d2zz5rkh9rdf6fqjbpx1mfdzzl6n7ghj-notmuch-0.29.3 /nix/store/1rx6bbd0fcw7h0shz1drrhza1flpvh0w-emacs-26.3
/nix/store/d2zz5rkh9rdf6fqjbpx1mfdzzl6n7ghj-notmuch-0.29.3
╚═══bin/notmuch-emacs-mua: …}".}..EMACS=${EMACS:-/nix/store/1rx6bbd0fcw7h0shz1drrhza1flpvh0w-emacs-26.3/bin/emacs}.EMACSCLIE…
    => /nix/store/1rx6bbd0fcw7h0shz1drrhza1flpvh0w-emacs-26.3

if $out/bin/notmuch-emacs-mua would be moved to another output, it wouldn't be downloaded if you would only download the out output from the binary cache.

I'm not exactly sure on how emacs integrates with notmuch works, and if moving bin/notmuch-emacs-mua would break emacs. spawning @tazjin and @andir on that ;-)

@tazjin
Copy link
Member

tazjin commented Apr 4, 2020

I'm not exactly sure on how emacs integrates with notmuch works, and if moving bin/notmuch-emacs-mua would break emacs. spawning @tazjin and @andir on that ;-)

notmuch-emacs-mua is used as the handler for mailto: links when other applications want to spawn the user's mail client. This will need to be propagated to the user's environment if they're using the standard notmuch client (i.e. notmuch.el).

@flokli
Copy link
Contributor

flokli commented Apr 4, 2020 via email

@tazjin
Copy link
Member

tazjin commented Apr 4, 2020

So if we'd move notmuch-emacs-mua to a separate emacs output and add some release notes explaining it now needs to be obtained from the notmuch.emacs output, this should be fine.

If you're splitting it, then the Emacs client itself should also be moved to that output to avoid confusion.

@flokli
Copy link
Contributor

flokli commented Apr 4, 2020 via email

@andir
Copy link
Member

andir commented Apr 6, 2020 via email

@tazjin
Copy link
Member

tazjin commented Apr 6, 2020

Don't we have a similar system for emacs?

Seems like something @adisbladis would know.

@flokli flokli mentioned this pull request Apr 7, 2020
10 tasks
@flokli
Copy link
Contributor

flokli commented Apr 7, 2020

There seems to be emacsPackages.notmuch, but these seem to come from another source, and don't seem to have a connection to pkgs.notmuch.

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.

None yet

7 participants