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

Nix integration #4149

Merged
merged 3 commits into from
Dec 6, 2016
Merged

Nix integration #4149

merged 3 commits into from
Dec 6, 2016

Conversation

ttuegel
Copy link
Member

@ttuegel ttuegel commented Dec 2, 2016

These commits add Nix integration to cabal-install. If the global --enable-nix option is specified and a shell.nix file exists, cabal will run the affected commands in a nix-shell instance.

@mention-bot
Copy link

@ttuegel, thanks for your PR! By analyzing the history of the files in this pull request, we identified @23Skidoo, @mightybyte and @dcoutts to be potential reviewers.

@23Skidoo
Copy link
Member

23Skidoo commented Dec 2, 2016

Nice!

Needs a note in the changelog, though. Will new-buildbe supported as well?

@23Skidoo
Copy link
Member

23Skidoo commented Dec 2, 2016

Also, would it be possible to set up some kind of CI for this stuff?

@k0001
Copy link

k0001 commented Dec 3, 2016

From nix-shell's man page:

nix-shell defaults to shell.nix if it exists, and default.nix otherwise.

Shouldn't cabal try and do the same so that the behavior of cabal is more predictable to nix-shell users?

Creating Nix Expressions
------------------------

The Nix package manager uses a functional language to describe packages, known as expressions. The fastest way to create a Nix expression for a Cabal package is with the ``cabal2nix`` tool. To create a ``shell.nix`` expression for the package in the current directory, run this command:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should it say "known as Nix expressions"?

Copy link
Member Author

Choose a reason for hiding this comment

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

@grayjay That's not quite what I meant. Does the updated version read better?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I think that's clearer.

@ttuegel
Copy link
Member Author

ttuegel commented Dec 3, 2016

Also, would it be possible to set up some kind of CI for this stuff?

@23Skidoo Maybe? I'm not sure what you have in mind, could you elaborate?

@ttuegel
Copy link
Member Author

ttuegel commented Dec 3, 2016

Shouldn't cabal try and do the same so that the behavior of cabal is more predictable to nix-shell users?

@k0001 Well, I thought about that. The fact that nix-shell respects default.nix is mostly a historical accident. Once there were no shell.nix files, but more and more packages need different expressions for building versus developing. This distinction is usually represented by having different shell.nix and default.nix files. In fact, the need to distinguish was mostly driven by Haskell packages! I imagine most Nix users will set nix: True in their ~/.cabal/config and I don't want them to get into trouble if a package doesn't provide shell.nix and its default.nix isn't suitable for nix-shell. But as you pointed out, Nix users may also be confused when they encounter a default.nix that is suitable for nix-shell, but gets ignored. What do you think?

@ttuegel ttuegel force-pushed the nix branch 2 times, most recently from 4489722 to 539ed62 Compare December 3, 2016 15:44
@k0001
Copy link

k0001 commented Dec 3, 2016 via email

@ttuegel
Copy link
Member Author

ttuegel commented Dec 4, 2016

At worst, if your default.nix is not nix-shell aware, you'll get some kind of error in the command line right away.

I can live with that!

@ttuegel
Copy link
Member Author

ttuegel commented Dec 5, 2016

@23Skidoo I'm getting timeouts on Travis. What is the etiquette for merging in that case?

@ezyang
Copy link
Contributor

ezyang commented Dec 5, 2016

It doesn't look like you made any changes that should have made the build go slower; the OS X machines are just inexplicably 20-50% slower than usual. Unfortunately, I don't see any reports on Travis CI. I went ahead and restarted the builds in hopes that it was just a temporary slowdown. If not, we'll have to play some games to get it down to acceptable level (maybe finally make cabal-install-lib so we don't have to build the cabal-install libraries three times to test them!)

@ezyang
Copy link
Contributor

ezyang commented Dec 6, 2016

Fixed!

@ttuegel ttuegel merged commit 2f289fc into haskell:master Dec 6, 2016
@ttuegel ttuegel deleted the nix branch December 6, 2016 15:43
@cstrahan
Copy link

Hey, this looks pretty great!

One thing I'm curious about: I'm almost always in a Nix shell, so I imagine I'd have to either open a fresh shell or invoke cabal as env -u IN_NIX_SHELL cabal .... Assuming my reasoning is correct, might it make more sense to use some other heuristic - perhaps an env var specifically for this purpose (e.g. CABAL_IN_NIX_SHELL)?

@ttuegel
Copy link
Member Author

ttuegel commented Dec 28, 2016

perhaps an env var specifically for this purpose (e.g. CABAL_IN_NIX_SHELL)?

That's a good idea. cabal should not care if it is initially executed inside a Nix shell; we only want to distinguish between "inside a shell started by cabal" and not.

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.

7 participants