[Nix-dev] use cabal2nix to create local nix environment for packages that aren't in nixpkgs
cdep.illabout at gmail.com
cdep.illabout at gmail.com
Tue Dec 2 14:09:06 CET 2014
Hi,
I posted the following question on Stackoverflow, but I received no
responses, so I thought this list might be more appropriate.
http://stackoverflow.com/questions/27215302/use-cabal2nix-to-create-local-nix-environment-for-packages-that-arent-in-nixpkg
I currently have a Yesod web application that I am developing on
NixOS. I am using a default.nix file like described in O'Charles' blog
post (https://ocharles.org.uk/blog/posts/2014-02-04-how-i-develop-with-nixos.html):
{ haskellPackages ? (import <nixpkgs> {}).haskellPackages }:
haskellPackages.cabal.mkDerivation (self: {
pname = "myblog";
version = "0.0.0";
src = ./.;
isLibrary = true;
isExecutable = true;
buildDepends = with haskellPackages; [
aeson bson conduit dataDefault fastLogger hjsmin
httpConduit monadControl monadLogger mongoDB persistent
#persistentMongoDB
persistentTemplate poolConduit shakespeare text
waiExtra waiLogger warp yaml yesod yesodAuth
yesodCore yesodDefault yesodForm yesodStatic
];
testDepends = with haskellPackages; [
hspec monadLogger persistent
#persistentMongoDB
resourcet transformers yesod yesodCore yesodTest
];
buildTools = with haskellPackages; [
cabalInstall ghcMod yesodBin
];
jailbreak = true;
})
This is working very well. I can use the yesod binary and cabal like
normal. However, I am running into one problem. When running cabal
haddock, I am getting the following error:
Running Haddock for mycoolblog-0.0.0...
Preprocessing library mycoolblog-0.0.0...
Warning: The documentation for the following packages are not installed. No
links will be generated to these packages: persistent-mongoDB-2.1.1
<command line>: cannot satisfy -package-id
aeson-0.8.0.2-9e93bdd6f8e68379314dd5f31414f87f
(use -v for more information)
Googling about this brings up the following link:
https://github.com/NixOS/nixpkgs/issues/2468
It seems like it is saying that ghcWithPackages should be used.
Googling about ghcWithPackages brings up O'Charles' (personal?) wiki
on Nix (http://wiki.ocharles.org.uk/Nix). It has an example of using
ghcWithPackages to develop a package that is already in nixpkgs, but I
can't get it to work with a package that is not already in nixpkgs (my
cms/blog).
Setting it up like described on O'Charles' wiki and running nix-shell
-v, I get the following error:
evaluating file
`/nix/store/an4sg7cxi1ii3vids8417kajl3ss13vd-nix-1.7/share/nix/corepkgs/derivation.nix'
error: cannot auto-call a function that has an argument without a
default value (`cabal')
Why am I getting the above error? How can I write a default.nix and
shell.nix for a Haskell project that's not already in nixpkgs? Ideally
it would be using ghcWithPackages so that cabal haddock works.
Thanks,
Dennis
More information about the nix-dev
mailing list