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
Fix buildStackProject in nix-build #30072
Fix buildStackProject in nix-build #30072
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know whether this change is good to have or not since I don't this code myself. I'll defer to other people's judgement. One comment I have:
If we ever create a top level package in all-packages using this, would we not want that cached?
We cannot compile Nix packages with stack, because stack cannot ensure a deterministic build outcome. Also, it needs all kinds of crazy network access to download its databases, etc. It might be possible work work around these issues somehow, but personally I just don't see the point because stack is fundamentally a developers tool, i.e. the features it provides are not important or even harmful in the context of Nix.
Ping @mboes |
I think that's selling Stack a little short. Certainly it's intention is to be a production tool, not just a dev tool. It is quite often used to build production deployments with it. The whole selling point is that it makes build reproducible. The only significant source of actual nondeterminism that I can think of is the ability to specify a branch for a git-based I understand that there are significantly more points of failure (in terms of reproducibility) with anything as heavily networked as Stack, but I do believe that nondeterministic builds are the outlier with it. I don't consider it worse than the other common forms of nondeterminism in Nix, like Granted, I'm a bit biased, as I don't even use Stack this way exactly. I do nutty stuff like this: { }:
let
nixpkgs = import ./nixpkgs {};
in nixpkgs.haskell.lib.buildStackProject {
ghc = nixpkgs.haskellPackages.ghcWithPackages ...; # Not the GHC given by stack!
...
} The nice thing about this is that I set the resolver to |
LGTM. Except for the |
f7f3369
to
590b8dc
Compare
@mboes @peti @domenkozar I've removed the |
LGTM |
Can we merge this please? |
Thanks! |
Is it normal that |
@wizzup Yea. Having the ability to use this with |
I am fine with dropping in nix-shell and run |
Motivation for this change
It seems that
haskell.lib.buildStackProject
never really worked fornix-build
, as it wouldn't have even hadstack
in thePATH
. The primary usage ofbuildStackProject
has always been to provide anix-shell
environment that Stack can use for its nix integration, but I see no reason that it can't also be used to perform a Stack build in Nix.This PR adds
stack
to thebuildInputs
, and correctly passes the arguments it expects when used with nix integration. The behavior innix-shell
is unchanged, thus leaving the user interface for stack's nix integration the same.EDIT: I also removed
preferLocalBuild
from the resulting derivation. It is unclear to me why that was there in the first place. If we ever create a top level package inall-packages
using this, would we not want that cached? I suspect it was that way becausenix-build
didn't previously matter for these derivations.Things done
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)