dhall-lang / dhall-haskell

Maintainable configuration files
https://dhall-lang.org/
BSD 3-Clause "New" or "Revised" License
912 stars 213 forks source link

Added dhall package command #2487

Closed mmhat closed 1 year ago

mmhat commented 1 year ago

Fixes #1645

Gabriella439 commented 1 year ago

Sorry for the delay, but I think the command-line interface I would suggest is:

$ dhall package "${DIRECTORY}"  # Create a `package.dhall` in that directory from its contents
$ dhall packages "${FILES[@]}"  # Create a `package.dhall` from those files if they all share the same directory, otherwise fail

… possibly with an optional --name option to select a name other than package.dhall. But generally I feel like we should try to promote the convention that the package file is named package.dhall and make that as ergonomic as possible.

Another advantage of doing it this way is that you don't need to worry about computing relative paths from the input files to the output package file, so it simplifies the implementation a lot.

mmhat commented 1 year ago

@Gabriella439 Thanks for the feedback; Yes, that would indeed simplify the implementation. I am a bit hesitant to add more than one new top-level command to the CLI - especially since the two you proposed are quite similar. Why do we want to distinguish the directory/files cases anyway?

However, if we were deciding to do that I'd propose:

$ dhall package directory "${DIRECTORY}"
$ dhall package files "${FILES[@]}"

What do you think about that?

mmhat commented 1 year ago

I changed the implementation to allow only files from the same directory and it is closer to the suggested behavior now. I did not yet change the CLI as the discussion about that is ongoing.

mmhat commented 1 year ago

No idea why the tests are failing on the Hydra build. They succeed on all other runners and I can't reproduce the failure locally.

Gabriella439 commented 1 year ago

this usually means that you need to add something to extra-source-files: https://github.com/dhall-lang/dhall-haskell/blob/0f1b05c82d8a7a88381f1d217de371499acba251/dhall/dhall.cabal#L26

… because the thing that the Nix build does differently is that it builds dhall from the source distribution that cabal would have generated and cabal will omit files that aren't explicitly mentioned in extra-source-files from the source distribution