Skip to content

Conditional inclusion of packages: #2048

Closed

Description

@hamishmack

Is there a way to do this? For instance we have this in leksah.cabal:

if os(osx)
    build-depends:
        gi-gtkosxapplication >=0.2.0.12 && <0.3

But if we want to include this in packages: we get:

No .cabal file found in directory /home/jpmoresmau/Documents/leksah/haskell-gi/bindings/GtkosxApplication/

In this case it is because haskell-gi cannot generate the package on Linux.

Could we perhaps add an optional-packages: section where stack would look for a .cabal file and only include the listed directory if a .cabal file was found?

CC @JPMoresmau

Activity

  1. mgsloan commented on Apr 19, 2016

    @mgsloan
    Contributor

    Related issue: #1722

    For now I would recommend having multiple stack.yaml files. Fancier config would be nice, but we have bigger fish to fry. It's been discussed in the past, and so far we've held off from doing fancy config merging / conditionals / environment interpolation. There are lots of benefits to having simple configuration.

    Alternatively, have a dummy cabal file in the package dir - it can be named something else to avoid it looking like it exists.

  2. added this to the P3: Optional milestone on Apr 19, 2016
  3. mgsloan commented on Oct 18, 2017

    @mgsloan
    Contributor

    Note that the inclusion here is just with stack build with no explicit targets. From the discussion on reddit, I just realized that you may not have been aware of the distinction between extra-dep and package. It's a bit non-obvious, but packages are things that should are built by default by stack build.

    In the package list, you can do the following:

    packages:
    - location: haskell-gi
      extra-dep: true

    See the relevant section of docs

  4. mgsloan commented on Oct 18, 2017

    @mgsloan
    Contributor

    Ah, I see now that the issue is that there is no cabal file. Eugh, how about just put a dummy cabal file there?

  5. dnadales commented on Oct 18, 2017

    @dnadales

    I've been following this issue but I'm not sure it is related to the problem we have. Due to licensing issues we need to build with using the integer-simple implementation on windows platforms, which forces us to have two stack files. For instance:

    stack.yaml (for windows):

    extra-deps:
    - text-1.2.2.2
    
    flags: 
      text: 
        integer-simple: true

    stack_linux.yaml:

    extra-deps:
    # Nothing, no problem with integer GMP licensing on Unix systems

    This not only doubles the maintenance efforts, but breaks editor tools on Linux (like intero) which expect a working stack.yaml file.

    I guess this issue cannot be solved in the way @mgsloan indicated, or can it?

  6. hamishmack commented on Oct 18, 2017

    @hamishmack
    Author

    Cool. It does looks like this is no longer an issue for Leksah (so we only need one stack.yaml now leksah/leksah@ee8b70f). Thanks.

  7. dtaskoff commented on Oct 24, 2017

    @dtaskoff

    @capitanbatata, I think your issue is #3369

  8. dnadales commented on Oct 24, 2017

    @dnadales

    @leohaskell It is indeed. But that one was closed, and it refers to this one. Do you also maintain two stack files?

  9. dtaskoff commented on Oct 24, 2017

    @dtaskoff

    @capitanbatata, it's not closed yet, it's in discussion state.
    Yes, I do maintain two stack files at the moment, but I hope that this will change soon.

  10. mgsloan commented on Oct 24, 2017

    @mgsloan
    Contributor

    It may be feasible / desireable to have conditionals that are in the same form as hpack, for consistency. Primary concerns:

    • Does this mean that stack configurations would get the equivalent of cabal flags? Another layer of toggleable flags?!

    • It complicates automated refactoring of stack.yaml. Perhaps the solution is to not worry about it.

    In general, it seems complicated to make the configuration more and more like a program, I like to keep it simple while handling 95% of cases. A potential workaround for y'all is to name neither of your stack.yaml files "stack.yaml", and have a simple ./configure.hs stack script which checks the environment and creates a symlink or copy of the appropriate stack.yaml

    I have to look at how much complexity / bug surface area / maintainability this would add to stack, atop the complexity of implementi0ng it the first place, versus how many times it's actually useful. Strongly leaning towards "have a ./configure.hs" script at least in the short to medium term.

    I haven't looked into dhall much, but it seems cool. Maybe one long term direction would be to switch to it. Then, many of the concerns of having programmatic configuration would not be the responsibility of the stack project.

  11. dnadales commented on Oct 25, 2017

    @dnadales

    I understand this might be tricky to implement, and maybe it could be solved somewhere else. Regarding the ./configure.hs script (or did you mean ./configure.sh ;) ) I don't know if you can make symbolic links on Windows platforms (starting from Windows 7 at least...). Is there a possibility that this conditional inclusion or selection of packages could be solved at the cabal level?

  12. dtaskoff commented on Oct 25, 2017

    @dtaskoff

    In general, it seems complicated to make the configuration more and more like a program, I like to keep it simple while handling 95% of cases.

    I completely understand that from a maintainability perspective.

    A potential workaround for y'all is to name neither of your stack.yaml files "stack.yaml", and have a simple ./configure.hs stack script which checks the environment and creates a symlink or copy of the appropriate stack.yaml

    This is the same as having multiple .yaml configurations and calling stack build --stack-yaml ... which is exactly the thing I don't want to do. The reason is that it's hard to keep all the configurations in sync, especially when they're dynamically changing (with each LTS, for example). In my case, I have four configurations and that's really a burden.

    A better thing to do is to have a configure.hs (it's not sh, @capitanbatata, it's a stack script), which joins a general configuration with a configuration specific for the current environment, but I'd still prefer to keep that in a single file, though if the configure.hs is carefully written, it's not that bad.

  13. dnadales commented on Oct 25, 2017

    @dnadales

    (it's not sh, @capitanbatata, it's a stack script),

    Thanks.

    Regarding how useful it would be, I guess that every Haskell project that aims at being multi-platform and not licensed under the GPL license will run into this issues, since on Windows you need libraries to use integer-simple.

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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions