Skip to content

Add support for (some) cabal.project-fields to cabal script-metadata #5698

Closed

Description

@hvr

The basic script feature (see #3843) implemented has support for including package-description/buildinfo fields but didn't yet implement support for project metadata.

At the very least fields such as index-state, with-compiler, allow-{newer,older} and constraints shall be supported as exemplified in the example below

#! /usr/bin/env cabal
{- cabal:
index-state: 2016-09-15T12:00:00Z
with-compiler: ghc-8.0.2
allow-newer: shelly:base
constraints: filepath==1.4.1.1, containers==0.5.7.1, Cabal installed, cryptonite -none

build-depends: base ^>= 4.9
             , shelly ^>= 1.6.8
-}

main :: IO ()
main = do
   ...

/cc @typedrat

Activity

  1. phadej commented on Nov 19, 2018

    @phadej
    Collaborator

    allow-newer

  2. 23Skidoo commented on Nov 19, 2018

    @23Skidoo
    Member

    We should also think about the backwards compat story for {- cabal: blocks while we're at it.

  3. hvr commented on Nov 19, 2018

    @hvr
    MemberAuthor

    @phadej good catch!

    @23Skidoo cabal: afaik is versioned; i.e. it's actually {- cabal:[<script-spec-version>] (and the spec ver is optional)

  4. 23Skidoo commented on Nov 20, 2018

    @23Skidoo
    Member

    @hvr

    cabal: afaik is versioned; i.e. it's actually {- cabal:[<script-spec-version>] (and the spec ver is optional)

    Is it documented somewhere which script-spec-version is the implicit one?

  5. 23Skidoo commented on Nov 20, 2018

    @23Skidoo
    Member

    Not against this proposal, but wouldn't something like

    #! /usr/bin/env cabal --allow-newer=foo,bar,baz
    

    work too?

  6. hvr commented on Nov 21, 2018

    @hvr
    MemberAuthor

    @23Skidoo Unfortunately, what is allowed under POSIX for portable shebang scripts is very limited; see https://en.wikipedia.org/wiki/Shebang_(Unix)#Portability for the sad story

    TLDR: the answer is "no" :-)

  7. 23Skidoo commented on Nov 21, 2018

    @23Skidoo
    Member

    okay.jpg

  8. cartazio commented on Nov 21, 2018

    @cartazio
    Contributor

    does this require the file be named Main.hs or have a module main? (i'm kinda interested in just making sure its easy to check / validate them?)

  9. maoe commented on Mar 30, 2020

    @maoe
    Member

    +1 to this feature. I also would like to be able to set verbose: 0 to suppress build messages.

  10. fendor commented on Apr 30, 2020

    @fendor
    Collaborator

    @23Skidoo

    Is it documented somewhere which script-spec-version is the implicit one?

    According to the code:
    https://github.com/haskell/cabal/blob/master/cabal-install/Distribution/Client/CmdRun.hs#L473
    It looks like 2.2

    And according to the parsing of the script-block: https://github.com/haskell/cabal/blob/master/cabal-install/Distribution/Client/CmdRun.hs#L379
    It uses the latest cabal-spec-version for parsing. Not sure if this means that it actually cant be overriden.
    It seems the current parser for meta-data allows anything that can be written in an executable stanza (it is actually possible to provide a main-is field, but it is overriden later on without warning).

    Using the parser for cabal.project and automatically writing it to the same fake-package seems rather easy to me! Are there more complex interactions that I should be aware of?


    EDIT: the syntax cabal:[<cabal-spec-version>] does not seem to parse.

  11. gbaz commented on Feb 17, 2022

    @gbaz
    Collaborator

    I think that rather than altering the grammar for this bloc (which now simply obeys a portion of cabal file grammar) we should just add another config bloc that obeys cabal.project/cabal.config grammar. (the former is I believe a superset of the latter). This should be much easier to implement.

  12. self-assigned this
    on Feb 18, 2022
  13. bacchanalia commented on Feb 18, 2022

    @bacchanalia
    Collaborator

    How do we feel about the following syntax?

    {- cabal:
    executableFields: vals
    
    -- cabal.project:
    projectFields: vals
    -}

    I think it looks clean, but might be confusing because -- project: looks like a comment.
    It also has the disadvantage that comments are valid inside of the block.

    Alternate:

    {- cabal:
    executableFields: vals
    
    cabal.project
    projectFields: vals
    -}

    Should the header be cabal.project or just project?

  14. gbaz commented on Feb 18, 2022

    @gbaz
    Collaborator

    I lean towards project as the header.

    I was actually thinking two blocs entirely as in

    {- cabal:
    executableFields: vals
    -}
    
    {- project:
    projectFields: vals
    -}
    
  15. cartazio commented on Feb 18, 2022

    @cartazio
    Contributor
  16. added a commit that references this issue on Feb 19, 2022
    bdd4594
  17. added a commit that references this issue on Feb 27, 2022
    8afefa4
  18. added a commit that references this issue on Mar 2, 2022
    aebe39a
  19. added a commit that references this issue on Mar 30, 2022
    459ef2d
  20. added a commit that references this issue on May 5, 2022
    2d2f007
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions