[Nix-dev] [Nix-Dev] Packaging a Haskell project using Stack

Sergey Mironov grrwlf at gmail.com
Wed Mar 15 12:22:06 CET 2017


Hi. I've just fixed and completed the ./unstack.sh script, allowing
users to generate Nix expressions for entire Haskell stack project
(and its dependencies). The URL is the same

https://github.com/grwlf/nixcfg/blob/unstable/ideas/unstack.sh

Regards,
Sergey

PS Please let me know if there is another tool for this task
(cabal2nix? stack itself?)

2017-01-10 13:20 GMT+03:00 Sergey Mironov <grrwlf at gmail.com>:
>>> I am to package Stack project which
>>>
>>>   1) depends on old lts-2.21 package set from stackage
>>>   2) doesn't have .cabals anymore, only .yamls.
>>>
>>> The question is basically How to do it?
>>
>> Run "hpack" to generate the Cabal files. Then run "cabal2nix" to
>> generate the Nix files. Add those Nix builds to Nixpkgs as explained in
>> the user's manual at:
>>
>>   http://nixos.org/nixpkgs/manual/#how-to-create-nix-builds-for-your-own-private-haskell-packages
>>
>
> OK, I've managed to create a prototype nix-shell script to packaging
> (not simply building) dependencies for a Stack project. Parameters are
> explained in its header.
>
> https://github.com/grwlf/nixcfg/blob/unstable/ideas/unstack.sh
>
> It works by
> 1) Calling stack list-dependencies
> 2) Calling cabal2nix for every dependency
> 3) Producing top-level all.nix expression
>
> The script is not for end-users yet, it doesn't produce final
> expression to build the Stack project, only its dependencies. Also,
> small modification of  pkgs/development/haskell-modules/default.nix is
> required: One should replace line `inherit mkDerivation callPackage;`
> with `inherit mkDerivation callPackage callPackageWithScope;`. Thus,
> callPackageWithScope function will be accessible for the script.
>
> Regards,
> Sergey


More information about the nix-dev mailing list