An Example would be helpful
Closed this issue · 6 comments
Thank you for this package.
I'm trying to use this to get into a development environment with the needed packages as specified by the stack.yaml but I can't make it work.
A small example of how this should work would be super helpful if possible :)
@archaeron there are two examples in https://github.com/input-output-hk/stack2nix#usage and stack2nix itself uses stack2nix. What part do you think is missing from those examples?
here is where I was stuck: https://gist.github.com/archaeron/d5238eb1fe5285a0df6328738b5571fe
I later found out that the problem was the old (newest current) version of stack2nix on hackage. After building through nix failed and building through vagrant failed, I managed to build it through stack and it is working now.
Can you paste Nix error?
Do you mean the nix error while building this?
This is the error I had: #112
https://gist.github.com/archaeron/02ca304fe72ac1eebf1285152b22bd15
The error the old version had was something with "package 'primitive' missing". but I've seen you just published a new version, so that should be fixed, thanks! :)
How do I get into a development environment for my package?
I tried nix-shell -A my-package.env but I can't find cabal in the path then.
lets merge into #112 112
For anyone coming here, hoping for an example, this is how I got it to work (not sure if this is the best way):
cabal2nix . > stack.nix
default.nix:
let
stackPackages = import ./nix/stack.nix { };
in
{
my-package = stackPackages.my-package;
my-package-shell = stackPackages.shellFor {
withHoogle = true;
packages = p: [p.my-package];
};
haskellPackages = stackPackages;
}
stack.nix:
{ pkgs ? import <nixpkgs> {} }:
let
packages = import ./default.nix;
in
if pkgs.lib.inNixShell
then packages.my-package-shell.overrideAttrs (oldAttrs: rec {
buildInputs =
[
packages.haskellPackages.cabal-install
packages.haskellPackages.ghcid
];
})
else packages
this allowed me to use nix-shell in that folder
and to use the cabal new-... commands with all necessary libraries installed