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

OS conditionals and flags in general #217

Open
acowley opened this issue Feb 9, 2016 · 3 comments
Open

OS conditionals and flags in general #217

acowley opened this issue Feb 9, 2016 · 3 comments

Comments

@acowley
Copy link

acowley commented Feb 9, 2016

I didn't find reference to this issue, so I wanted to ask it as broadly as possible: is there an intention to better support cabal flags such as compiler version conditionals, but particularly operating system conditionals?

As things stand, the generated Nix is very Linux-centric. To accommodate the switching logic expressible in the Cabal language would mean some burden on existing Linux users in the form of more complex Nix expressions that replicate that logic. In my cabbage tool, for instance, there is support for dealing with framework dependencies needed on OS X. With the nixpkgs Haskell infrastructure, these can be shoe-horned into buildInputs so that they are propagated, but it requires per-package reconfiguration. There are additionally changes to the other dependency fields depending on the platform (e.g. the OpenGL framework on OS X vs. mesa on Linux).

I can make PRs to fix this for darwin users on a case-by-case basis in configuration-common.nix as I encounter problems, or the configuration logic can be pushed down into the derivations themselves. Do the Haskell infrastructure maintainers have an opinion on this?

@peti
Copy link
Member

peti commented Feb 10, 2016

@acowley
Copy link
Author

acowley commented Feb 10, 2016

This is excellent, thank you! I had been thinking that a relatively easy, low-impact option would be to generate per-platform derivations when an os conditional is used in a cabal file, but that still leaves flags not particularly well supported. I think what you've already done with flags is actually quite good, frankly, but the per-platform build dependencies are a killer.

They're also a bit tricky to convert to Nix for two main reasons:

  1. They are not necessarily all in one place, but have a cumulative appending behavior on the list of dependencies.

  2. They have default fall-through on conditionals. A cabal author today can somewhat effectively target darwin by writing

if os(linux) || os(windows)
  ...
else
  -- darwin things

The latter point is why I started thinking about per-platform derivations as we could then just ask for the cumulative options for each supported platform and let the Cabal library figure it all out. One strategy would be to collapse the per-platform logic with Cabal, and then combine them all into one Nix expression that guards the differences.

@peti
Copy link
Member

peti commented Jun 15, 2016

The newly introduced callHackage function solves this problem (almost) completely because the generated Nix expressions will be created specifically for the targetted OS and compiler. There's no support for specifying flags yet, but that should be easy to add.

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

No branches or pull requests

2 participants