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

Haskell shell completion #106591

Merged

Conversation

roberth
Copy link
Member

@roberth roberth commented Dec 10, 2020

Motivation for this change

Make shell completion work for more haskell commands.

niv and ormolu require the "support separate bin" commit. Otherwise, it doesn't work when niv.bin is used, which is how pkgs.niv is defined (as opposed to haskellPackages.niv).

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.

bashCompDir="$out/share/bash-completion/completions"
zshCompDir="$out/share/zsh/vendor-completions"
fishCompDir="$out/share/fish/vendor_completions.d"
bashCompDir="''${!outputBin}/share/bash-completion/completions"
Copy link
Member

Choose a reason for hiding this comment

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

What does ${!outputBin} do here? Is it more appropriate than ${out}?

Copy link
Member Author

Choose a reason for hiding this comment

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

$outputBin is "bin" or "out".
${!x} is a double lookup of x, so ${!outputBin} evaluates to either $bin or $out.

Copy link
Member

Choose a reason for hiding this comment

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

I am sorry, that I ask stupid questions here, but I am curious about that variable and the manual didn’t enlighten me.
I know what $out does, but how would $bin look like in which kind of derivations is ${outputBin} = $bin?
For my uninformed eyes the $bin/bin/... in this change looks like a potential bug.

Copy link
Member

Choose a reason for hiding this comment

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

To clarify: My naive expectations would be that $bin = $out/bin

Copy link
Member Author

Choose a reason for hiding this comment

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

$bin is just the bin output store path e.g /nix/store/...-niv-1.0-bin, $bin/bin is the "FHS" bin directory inside the separate bin output /nix/store/...-niv-1.0-bin/bin.

I'll also point out that the bin output isn't limited to having only a bin directory. It makes sense to have supporting files like this in the same output. A data or share output is not helpful because it's only used in conjunction with bin, negating potential closure size benefits and doing so creates a risk of creating a reference cycle in the output, which is not allowed.

Copy link
Member

@cdepillabout cdepillabout left a comment

Choose a reason for hiding this comment

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

Could you rebase this on the haskell-updates branch?

Also, is this related at all to NixOS/cabal2nix#474 by @zimbatm?

@roberth roberth marked this pull request as draft December 11, 2020 08:07
@roberth roberth changed the base branch from master to haskell-updates December 11, 2020 08:08
@roberth roberth marked this pull request as ready for review December 11, 2020 08:08
@roberth
Copy link
Member Author

roberth commented Dec 11, 2020

Could you rebase this on the haskell-updates branch?

Done.

Also, is this related at all to NixOS/cabal2nix#474 by @zimbatm?

It has the same goal, but those packages don't use optparse-applicative, so the implementation is different.
I'm surprised to see these overrides implemented in cabal2nix. Doesn't that make it harder to contribute to it?

Copy link
Member

@maralorn maralorn left a comment

Choose a reason for hiding this comment

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

Thx, for the explanation. Code looksreasonable. Tests pass. LGTM

Copy link
Member

@zimbatm zimbatm left a comment

Choose a reason for hiding this comment

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

nice!

@cdepillabout
Copy link
Member

Thanks!

I'm surprised to see these overrides implemented in cabal2nix. Doesn't that make it harder to contribute to it?

I'm not sure of the full backstory, but I think the idea is that if you put overrides directly into cabal2nix, they will work for anyone running cabal2nix (even if they are not using the package set from nixpkgs).

This used to be important when there were tools like stack2nix that directly made use of cabal2nix, but maybe not as important anymore?

@cdepillabout cdepillabout merged commit 090b1d4 into NixOS:haskell-updates Dec 12, 2020
@maralorn
Copy link
Member

maralorn commented Dec 12, 2020

@cdepillabout I had a discussion about that with peti last friday. It's exactly for the reason you say. We are brainstorming right now about redesigning the process (something which we really want to hear your opinion about, btw. we‘d like to schedule a meeting as soon as we get to it), one longterm goal might be to migrate all those overrides into nixpkgs and having tooling that can generate derivations will taking overrides defined in nixpkgs into account.

@zimbatm
Copy link
Member

zimbatm commented Dec 12, 2020

one longterm goal might be to migrate all those overrides into nixpkgs and having tooling that can generate derivations will taking overrides defined in nixpkgs into account.

That's probably the best option. We have been using that approached in the ruby packages and it has been working quite well.

The biggest advantage is that the haskell packages can be fixed, without having to re-release cabal2nix.

@roberth
Copy link
Member Author

roberth commented Dec 12, 2020

to migrate all those overrides into nixpkgs and having tooling that can generate derivations will taking overrides defined in nixpkgs into account.

This sounds exactly like how I expected it to work. 👍

@cdepillabout
Copy link
Member

@maralorn

We are brainstorming right now about redesigning the process (something which we really want to hear your opinion about

To be honest, I don't really have strong opinions either way.

It seems like a lot of people just end up using callCabal2nix (or the related callHackage), so as long as those work nicely with cabal2nix, I'm happy.

The biggest advantage is that the haskell packages can be fixed, without having to re-release cabal2nix.

I agree that this does sound nice, but maybe another solution would be to add more people as maintainers for cabal2nix and push out releases faster.

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

4 participants