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

Support Nix in cabal-install #3651

Closed
ttuegel opened this Issue Aug 1, 2016 · 11 comments

Comments

Projects
None yet
6 participants
@ttuegel
Copy link
Member

ttuegel commented Aug 1, 2016

Stack has been integrated with Nix for some time. We are actually in a better position in terms of integration because we keep persistent configuration data. Full integration would take a modest amount of additional work:

  • add command-line flags and configuration options to enable or disable integration
  • if Nix is enabled and the project has a shell.nix file, instantiate it to a shell.drv during cabal configure
  • if Nix is enabled, wrap all calls to cabal ... in nix-shell: nix-shell --run "cabal ..."

This is slightly different than Stack's approach because it requires a shell.nix file, but the cabal2nix utility can generate those automatically from any .cabal file (and most Nix+Haskell users would be familiar with this tool).

@ezyang

This comment has been minimized.

Copy link
Contributor

ezyang commented Aug 1, 2016

Not a Nix-user, but if a Nixer (I guess you?) maintains the code I don't see any problem with putting this into cabal-install.

@ttuegel

This comment has been minimized.

Copy link
Member

ttuegel commented Aug 1, 2016

Not a Nix-user, but if a Nixer (I guess you?) maintains the code I don't see any problem with putting this into cabal-install.

That's the idea, to wean me away from Stack! 😉

For posterity, here is the zsh function I've been using to do the same thing:

nix-cabal () {
    CABAL=$(whence -p cabal)  # always use same cabal as current shell
    if [[ -a "$PWD/.shell.drv" ]]; then
        nix-shell --add-root "$PWD/.result" --indirect \
            "$PWD/.shell.drv" --run "$CABAL $*"
    elif [[ -a "$PWD/shell.nix" ]]; then
        nix-instantiate --add-root "$PWD/.shell.drv" --indirect \
            "$PWD/shell.nix" -A env
        nix-shell --add-root "$PWD/.result" --indirect \
            "$PWD/.shell.drv" --run "$CABAL $*" || rm "$PWD/.shell.drv"
    else
        nix-shell --add-root "$PWD/.result" --indirect --run "$CABAL $*"
    fi
}

I realize that probably means next to nothing to non-Nix-users; I just wanted to illustrate that the maintenance burden can be small because the logic doesn't need to be as complicated as Stack makes it.

@ryantrinkle

This comment has been minimized.

Copy link
Contributor

ryantrinkle commented Aug 29, 2016

@ttuegel That looks really nice! I hope you don't mind me stealing some of that logic for my own scripts :)

@guaraqe

This comment has been minimized.

Copy link

guaraqe commented Sep 2, 2016

This would be extremely welcome!

@ezyang ezyang added this to the milestone Sep 8, 2016

@ezyang

This comment has been minimized.

Copy link
Contributor

ezyang commented Sep 8, 2016

Not a priority for 2.0, but @ttuegel if you think you can figure something out in time for 2.0 we can remilestone

@ttuegel

This comment has been minimized.

Copy link
Member

ttuegel commented Sep 8, 2016

@ezyang I agree it's not a priority for 2.0. I've discussed this with several Nix people, and I think it will work better with new-build anyway. Maybe we could make a milestone for 3.0? I usually milestone things as _|_ only when nobody has any intention of working on them.

@ezyang ezyang modified the milestones: Default nix-local-build, Sep 8, 2016

@ezyang ezyang added the priority: low label Sep 8, 2016

@ttuegel

This comment has been minimized.

Copy link
Member

ttuegel commented Sep 11, 2016

I am re-milestoning this because #3728 is blocked on it; however, I don't think either should be a release blocker.

@ttuegel

This comment has been minimized.

Copy link
Member

ttuegel commented Sep 12, 2016

After some conversation with @ezyang, I think that #3728 is not really blocked on this. I am going to leave it on the 2.0 milestone at low priority, though, because I have already implemented most of it 😃

@23Skidoo 23Skidoo modified the milestones: 2.0.1, 2.0 Feb 17, 2017

@23Skidoo

This comment has been minimized.

Copy link
Member

23Skidoo commented Feb 17, 2017

@ttuegel Can this ticket be closed as fixed?

@ttuegel

This comment has been minimized.

Copy link
Member

ttuegel commented Feb 17, 2017

Indeed, I pushed the fix for this but completely forgot about the issue!

@ttuegel ttuegel closed this Feb 17, 2017

@23Skidoo 23Skidoo modified the milestones: 2.0, 2.0.1 Feb 17, 2017

@ysangkok

This comment has been minimized.

Copy link

ysangkok commented Feb 17, 2017

Seems like this was fixed in #4193

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