nmattia / snack

Nix-based incremental build tool for Haskell projects
334 stars 25 forks source link

add hie-bios command #199

Open hyperfekt opened 4 years ago

hyperfekt commented 4 years ago

This adds support for hie-bios. Since hie-bios can't call a program with arguments (https://github.com/mpickering/hie-bios/issues/158), the following files are needed in the project:

hie.yaml:

cradle: {bios: {program: ".hie-bios"}}

.hie-bios:

#! /bin/sh
snack hie-bios $@

Closes #178.

hyperfekt commented 4 years ago

Currently extra-directories are not yet implemented since I could not find a corresponding flag for GHC, and trying to use it with Digital Asset's ghcide will fail due to https://github.com/digital-asset/ghcide/issues/551.

hyperfekt commented 4 years ago

I've thought about this and while I could add flags to add extra-directories as all kinds of different flags GHC offers for specifying search paths for different kinds of files, this would still not cover all uses (for example Template Haskell as used in Snack itself). The real solution would be to have hie-bios ask on behalf of its dependents for directories to add to the PATH for a session, or for GHC to add a flag to add directories to the PATH (which would also need to be reflected in its API). A workaround would be to add all those directories to the PATH of hie-bios dependents like it is done for GHCi by Snack right now, which of course has the problem of collisions between files in extra-directories in different packages. Another option would be to allow extra-directories only in the root project (or even get rid of it entirely, in which case TH would have to call out to Nix I guess?) so that collisions are not a possibility.

hyperfekt commented 4 years ago

I implemented shell commands for hie-bios so maybe this command should not be hie-bios specific, and output the flags to stdout instead, and the shell command can be used to pipe that into the file required by hie-bios.