-
Notifications
You must be signed in to change notification settings - Fork 706
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
Comments
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. |
@ttuegel That looks really nice! I hope you don't mind me stealing some of that logic for my own scripts :) |
This would be extremely welcome! |
Not a priority for 2.0, but @ttuegel if you think you can figure something out in time for 2.0 we can remilestone |
@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 |
I am re-milestoning this because #3728 is blocked on it; however, I don't think either should be a release blocker. |
@ttuegel Can this ticket be closed as fixed? |
Indeed, I pushed the fix for this but completely forgot about the issue! |
Seems like this was fixed in #4193 |
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:
shell.nix
file, instantiate it to ashell.drv
duringcabal configure
cabal ...
innix-shell
:nix-shell --run "cabal ..."
This is slightly different than Stack's approach because it requires a
shell.nix
file, but thecabal2nix
utility can generate those automatically from any.cabal
file (and most Nix+Haskell users would be familiar with this tool).The text was updated successfully, but these errors were encountered: