cabbage
cabbage copied to clipboard
build tools
I have a project that requires c2hs. I tried making a cabbage.config
containing
systemDeps:
c2hs: c2hs
but this results in a warning and a possibly unrelated error from find
WARNING: cabal get did not unpack c2hs
Should we continue? [Y/n]
find: warning: you have specified the -depth option after a non-option argument -name, but options are not positional (-depth affects tests specified before it as well as those specified after it). Please specify options before other arguments.
find: paths must precede expression: 1
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
WARNING: Couldn't find build tool: c2hs
when running cabbage
. When I try to run nix-shell --command 'sh $setup'
nevertheless I get the following error
error: anonymous function at "/home/moritz/code/haskell/reactand/default.nix":1:1 called without required argument ‘c2hs’, at "/nix/store/lgjabak42v2hp51dvj3fc0c3pxpnkk9h-nixpkgs-15.06pre63073.f0311f9/nixpkgs/lib/customisation.nix":58:12
I have c2hs in my path but nix probably needs it's own version.
I don't think you need that cabbage.config
file. The warning message is awful, and most likely due to an existing directory with c2hs
's source. What happens is that the script calls cabal get
, and looks at the exit code. Sometimes cabal get
fails because the package doesn't exist (eg a typo in a cabal file), but it also fails if the output directory already exists. I'll change things to do the directory check myself as it's a common cause for this warning.
The last message suggests that the shell.nix
isn't setting up c2hs
. If you've had problems, it's worth deleting shell.nix
and letting cabbage generate a new one.
I chose not to overwrite an existing shell.nix
in case someone had deliberately customized it, but it's a nuisance having to manually delete it when something went wrong with Nix file generation (as probably happened to you). I'm not sure how to distinguish the two. I can prompt the user about overwriting and move the existing shell.nix
to another file on timeout (with a default answer of, "Yes, overwrite"). Does that sound right?
I don't think that's it. I tried deleting default.nix
, shell.nix
, cabbage.config
, .cabbages
and ran cabal clean
and cabal sandbox delete
. Then I reinitialized the sandbox using cabal sandbox init
followed by a cabal sandbox add-source /path/to/library
. Then I ran cabbage
again followed by nix-shell --command 'sh $setup'
and the error messages on both commands are exactly the same.
Regarding overwriting it, I think that's a good idea. I don't like timeouts at all, but since they are already used for other stuff in cabbage I guess it's fine to use them here too.
Weird. So the way it should work is that the generated default.nix
defines a function, one of whose parameters is c2hs
because it's listed as a build-tool. That seems to have worked, because it's expecting that argument. Lastly, shell.nix
is generated, and it ensures that the union of required build-tools is built before building the packages that depend on them. So, first, is the shell.nix
pulling in c2hs
, and then passing it through to the top-level default.nix
? Second, is the top-level default.nix
passing c2hs
to the package that needs it?
Something I need to clarify in the docs about sandboxes: Running cabbage will delete any existing sandbox and create a new one every time, but it keeps track of add-source
'd paths and adds them to the recreated sandbox. So, in general, you don't need to delete and init the sandbox yourself.
Here is shell.nix
let pkgs = import <nixpkgs> {};
mynix = import <mynix>;
haskellBuildTools = with mynix; [ ghcDefault cabalDefault ];
in pkgs.callPackage ./default.nix {
inherit pkgs haskellBuildTools;
}
I suppose that c2hs is in haskellBuildTools, but I am not actually sure where that's coming from, so I can't check.
default.nix
contains
wlc-hs = callPackage .cabbages/wlc-hs-0.1.0.0 {
inherit frozenCabbages haskellBuildTools pkgs c2hs;
};
which is the correct package so I guess that's correct. If it helps, I am trying it on my repo reactand and the add-source dependency is wlc-hs. However I don't think wlc-hs will work on OS X, but as the error seems to be before it actually tries to build it, you might still be able to reproduce the error.
Thanks for the clarification on sandboxes.
I'll have to run this down. The shell.nix
should be calling c2hs
explicitly, so something's gone wrong there.