NixOS/nixpkgs — pull request #3915 by Fuuzetsu (2014-09-01 00:52:49+00:00)
Title: RFC: Agda builder

Below is a builder for Agda libraries. Unlike Haskell, there is no cabal or anything of the sort to tell us about the package. The common practice is for authors to expose a file to compile, commonly `Everything.agda`.

Simply, it does the following

* Prepare `-i` flags to call agda with

* Create a wrapped binary in front of PATH and make AGDA_PACKAGE_PATH. This is mostly for benefit of tooling: in `nix-shell` we now have to only call `agda` and all our dependencies are accounted for. `buildTools` don't get accounted for here.

* Compile the files under specified directories and copy them under `$out/share/agda`. There is no canonical place to put it but if all packages put it there then we can always find the files that way. An alternative way would be to put a script at the top level at build time which can tell us where in the tree to find the files but benefit of this is dubious and I feel user-experience would suffer.

As proof of concept I converted the existing stdlib expression to use the new builder. I also packaged the `categories` library using it. It's not included because it the library happens to not compile with the recent update to Agda 2.4.2 but otherwise there is nothing wrong with it, I tested with previous version. You can see the expression [here](https://github.com/Fuuzetsu/nixpkgs/commit/0ab9900d6fa1a6590edb4e5325d106d13f75eb2d). As you can see it's nice and short.

This is a step up from how `stdlib` was packaged: abuse the cabal file inside of it and do everything manually in `postInstall`.

I think this could be made more resillent but I think most of all it just needs a bit of testing by others. cc @johnw who's listed under Agda things.