Navigation Menu

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: set buildInputs in nix-shell env #32821

Merged
merged 1 commit into from Dec 20, 2017

Conversation

ttuegel
Copy link
Member

@ttuegel ttuegel commented Dec 18, 2017

Motivation

nix-shell for Haskell projects with foreign library dependencies is broken because GCC cannot find headers or libraries.

systemBuildInputs goes in buildInputs (instead of nativeBuildInputs) so that
NIX_CFLAGS_* is set correctly and gcc works.

Testing

  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • 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 nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

Because Haskell packages use a separate shell environment not derived from the build environment, this should not affect the build of anything in Nixpkgs.

systemBuildInputs goes in buildInputs (instead of nativeBuildInputs) so that
NIX_CFLAGS_* is set correctly and gcc works.
@peti
Copy link
Member

peti commented Dec 19, 2017

This has come up before. Personally, I don't want system libraries to be found automatically. I want the necessary search paths to be configured with Cabal so that these paths are recorded in the generated package config files. This is necessary for packages compiled inside of a nix-shell environment to work outside of that environment, too.

@peti
Copy link
Member

peti commented Dec 19, 2017

See also #28033 for previous discussions.

@ttuegel
Copy link
Member Author

ttuegel commented Dec 19, 2017

Do you think your concerns in #28033 are still relevant now that both cabal and stack read shell.nix?

@ttuegel
Copy link
Member Author

ttuegel commented Dec 19, 2017

In any case, systemBuildInputs should not be in nativeBuildInputs because these inputs are for the host machine, not the build machine. So if you don't want systemBuildInputs to go into buildInputs, then they should be removed entirely.

@Profpatsch
Copy link
Member

now that both cabal and stack read shell.nix?

Didn’t know about that, sounds like a horrible solution. Suddenly every build tool knows about every other build tool 😟.

This has come up before. Personally, I don't want system libraries to be found automatically. I want the necessary search paths to be configured with Cabal so that these paths are recorded in the generated package config files.

Since there’s now multiple people who independently requested picking up the shell environment, maybe it’s time to find a compromise that works for both use cases?

@ttuegel
Copy link
Member Author

ttuegel commented Dec 20, 2017

Didn’t know about that, sounds like a horrible solution. Suddenly every build tool knows about every other build tool 😟.

I think we've been back and forth about this before. I see what you're saying, but let me counter: Nix is set up like a build server; cabal is just using it like one!

It's better than this situation:

the necessary search paths to be configured with Cabal so that these paths are recorded in the generated package config files

This only works because of a bug in cabal that the package config cache is not invalidated when the environment changes. And when the cache is finally invalidated, it breaks the cache regeneration. Finally, when cabal projects are enabled by default, it probably won't work at all because the cache invalidation bug will be fixed.

Since there’s now multiple people who independently requested picking up the shell environment, maybe it’s time to find a compromise that works for both use cases?

Overlays?

@peti
Copy link
Member

peti commented Dec 20, 2017

In any case, systemBuildInputs should not be in nativeBuildInputs because these inputs are for the host machine, not the build machine. So if you don't want systemBuildInputs to go into buildInputs, then they should be removed entirely.

You are right, that is a good point. Let's fix that issue now and worry about whether to remove them entirely or not in a separate PR.

@peti peti merged commit c1dcbad into NixOS:master Dec 20, 2017
@ttuegel ttuegel deleted the haskell/shell-env-build-inputs branch December 20, 2017 20:18
@Ericson2314
Copy link
Member

I'll fix this. The solution is a wrapped cabal install and a setup hook such that.

  1. NIX_CFLAGS doesn't get the -isystems and -Ls
  2. NIX_CABAL_FOREIGN gets the --extra-*-dirs instead

Then we properly specify all the deps exactly the same way in generic build and shell environments. In fact, we can use the setup hook with generic builder too.

@Ericson2314
Copy link
Member

If anyone can review #33358 in the meantime, that would be nice. It will be easier to get the dependency types correct with that in place.

@Ericson2314
Copy link
Member

Ericson2314 commented Jan 3, 2018

WIP #33368

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

5 participants