Skip to content

os/platform-specific fields in stack.yaml #3369

Open

Description

@dtaskoff

I think it would be nice to have a way of specifying fields that are os-specific. Something like this:

os-specific:
  windows:
    ghc-variant: integersimple
    flags:
      hashable:
        integer-gmp: false
      sceintific:
        integer-simple: true
...

Thus, one can keep more build information within stack and write less additional scripts.

NOTE: This could be possible also by modifying the confHook in Setup.hs if stack didn't bypass the configure step.

Activity

  1. mgsloan commented on Aug 21, 2017

    @mgsloan
    Contributor

    Potentially related issue: #2048

    Adding conditionals could be a bit complicated, might be worth it though. I don't have a strong feeling about it, but historically we've avoided making the configuration format very fancy.

  2. decentral1se commented on Aug 21, 2017

    @decentral1se
    Member

    I would mark this as a duplicate of #2048, no?

    #2048 (comment) seems to be the best solution for this so far.

  3. dtaskoff commented on Aug 21, 2017

    @dtaskoff
    Author

    It's not a duplicate of it, although the mentioned solution works in this case too. However, I'm not talking about packages, I'm talking about all building flags/options, which could be different depending on the OSes.

  4. saurabhnanda commented on Jul 26, 2018

    @saurabhnanda

    Is there a way to specify platform specific stack overrides in my home folder, i.e. outside of the project root?

    I'm on mac osx and need different cabal flags for hlibsass, while everyone else on my team is on linux and needs different flags.

  5. dtaskoff commented on Aug 6, 2018

    @dtaskoff
    Author

    @saurabhnanda, if you need different cabal flags only, you can pass them to stack like this:
    stack build --flag hlibsass:externallibsass

  6. pwaller commented on Dec 15, 2018

    @pwaller

    Lacking this is a significant pain. For example, we build llvm-hs with -f-shared-llvm, except on Darwin, where this is not currently supported. The effect is that you must remember to pass --flags or use our custom make targets which pass appropriate --flags out according to your current environment.

    If you ever use a stack command instead of make and forget to pass appropriate flags, it results in rebuilding the LLVM bindings and GTK (which requires --flag gtk:have-quartz-gtk on Darwin), which both take significant time.

  7. dbaynard commented on Dec 15, 2018

    @dbaynard
    Contributor

    To be clear, this is flags for dependencies, correct?

    For a package itself one can use the os conditional in the cabal/hpack file.

    One can set flags in a machine's config.yaml, rather than the project's stack.yaml. Would this work for your use case?

  8. pwaller commented on Dec 15, 2018

    @pwaller

    To be clear, this is flags for dependencies, correct?

    Yes. The packages whose flags need to be influenced are not under my control.

    One can set flags in a machine's config.yaml, rather than the project's stack.yaml. Would this work for your use case?

    That's not great either, since it is an additional step that must be documented and remembered to be done during setup of the machine. It would be much better if it were simply a property of the stack.

  9. dbaynard commented on Dec 15, 2018

    @dbaynard
    Contributor

    I can see good reasons to have such tooling. In one sense it is similar to haddock — often there are haddock build failures with dependencies, but stack currently has no way to indicate that a build should ignore these (the stackage-curator tool does, however).

    This broadens the proposal slightly — perhaps it would be better to invert the tree:

    ghc-variant:
      windows: integersimple
    flags:
      hashable:
        windows:
          integer-gmp: false
      scientific [sic]:
        windows:
          integer-simple: true
    

    That way any key (within some subset of the top level keys, perhaps) can have such conditionality.


    For the examples I've seen, however, it seems the best case is actually to fix these issues upstream. For example, while it would be very useful to have the haddock workaround, the real fix would be for upstream libraries to fix their docs.

    Likewise,

    …we build llvm-hs with -f-shared-llvm, except on Darwin, where this is not currently supported.

    Surely this should be fixed by llvm-hs setting that flag to false? And if they can't do that, you could fork the package, change the cabal file, and use a custom snapshot which uses your fork?

  10. pwaller commented on Dec 15, 2018

    @pwaller

    Surely this should be fixed by llvm-hs setting that flag to false? And if they can't do that, you could fork the package, change the cabal file, and use a custom snapshot which uses your fork?

    Well, whether to use shared llvm or not is a choice, depending on whether you want to statically compile your executable or not. I can see strong arguments for using either, but in my particular case I require them to be statically linked. I can't enforce that decision on the upstream project, it might not be appropriate for other users.

    Something like gtk:have-quartz-gtk might be a bug, I don't know. I don't really understand why the default would be something that doesn't build (in fact fails with some quite bad error messages) on Darwin. But again in this case, I assume that it must be this way for a reason, and perhaps there are reasons I'm unaware of...

  11. dbaynard commented on Dec 15, 2018

    @dbaynard
    Contributor

    Ah, yes, if its a choice then that's different — and should be fixable without forking.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions