Discussion:
[Nix-dev] stack2nix first public release (0.1.3.0)
Domen Kožar
2017-06-28 14:37:18 UTC
Permalink
Hi all,

I have just pushed to nixpkgs master `stack2nix` package that was developed
at IOHK
with the purpose of automating package set curated by stack tool into Nix
expressions.

Quick start (using latest master branch) using pandoc:

$(nix-build -A stack2nix)/bin/stack2nix --revision
242e2a064f6a32b22e1599bbfe72e64d7b6203b8 https://github.com/jgm/pandoc.git
demo.nix
nix-build -A pandoc demo.nix -I nixpkgs=`pwd`

How does stack2nix work? It uses cabal2nix under the hood based on package
list returned by `stack list-dependencies` output.

Note that calling stack2nix is impure, it will call "git clone",
"cabal2nix", "cabal update", etc., so
ideally when used with a CI, one needs to verify that the returned package
set is always up to date.

Note that since different Nix packages are generated than what is shipped
with nixpkgs, there is no binary cache.

Source code & issues: https://github.com/input-output-hk/stack2nix

The work was mostly done by Jake Mitchell.

Domen
ElvishJerricco
2017-06-28 14:59:44 UTC
Permalink
Awesome! I've wondered about something like this for a long time!

Why does it need `cabal update`? It seems like it should only need `git clone`, since it can use `haskellPackages.callHackage` for any Hackage dependencies.

- Will Fancher
Domen Kožar
2017-06-30 07:51:31 UTC
Permalink
It needs `cabal update` to fetch latest package index as it may need the
very new package index.

callHackage will generate Nix expression on each call, which does bring
some overhead. It's better
to generate expressions in a file that can be read with an editor.
Post by ElvishJerricco
Awesome! I've wondered about something like this for a long time!
Why does it need `cabal update`? It seems like it should only need `git
clone`, since it can use `haskellPackages.callHackage` for any Hackage
dependencies.
- Will Fancher
_______________________________________________
nix-dev mailing list
https://mailman.science.uu.nl/mailman/listinfo/nix-dev
Peter Simons
2017-06-30 08:49:31 UTC
Permalink
Hi Domen,
Post by Domen Kožar
callHackage will generate Nix expression on each call, which does
bring some overhead.
I'm pretty sure that it won't do that. Unless the generated expressions
are garbage collected, they won't be re-built.

Best regards,
Peter
Domen Kožar
2017-06-30 08:53:25 UTC
Permalink
Post by Peter Simons
Hi Domen,
Post by Domen Kožar
callHackage will generate Nix expression on each call, which does
bring some overhead.
I'm pretty sure that it won't do that. Unless the generated expressions
are garbage collected, they won't be re-built.
That was my point, you generate new Nix files additionally.

Regardless, afaik it doesn't resolve the need for `cabal update`.

stack2nix uses hnix to modify the cabal2nix output a bit, to strip out test
dependencies,
so until this approach is taken, we can't use callHackage.
Peter Simons
2017-06-30 09:13:36 UTC
Permalink
Hi Domen,

I am sorry: I misread your posting. Somehow I thought you had written
that callHackage would *re-generate* the Nix expression on each call,
which it doesn't, but that's not what you wrote.

Best regards,
Peter
Domen Kožar
2017-06-30 09:17:19 UTC
Permalink
I should have worded it clearly :)
Post by Peter Simons
Hi Domen,
I am sorry: I misread your posting. Somehow I thought you had written
that callHackage would *re-generate* the Nix expression on each call,
which it doesn't, but that's not what you wrote.
Best regards,
Peter
_______________________________________________
nix-dev mailing list
https://mailman.science.uu.nl/mailman/listinfo/nix-dev
Continue reading on narkive:
Search results for '[Nix-dev] stack2nix first public release (0.1.3.0)' (Questions and Answers)
37
replies
Any good books?
started 2008-05-29 17:49:29 UTC
books & authors
Loading...