I try using haskell's developPackage but the
{ pkgs ? import <nixpkgs> {} }:
devPkg = pkgs.haskellPackages.developPackage {
root = ./hs;
};
in
devPkg
that I run from a folder that contains hs/hs.cabal
and the haskell source code. Then I run nix-shell
$ nix-shell shell-develop.nix
building '/nix/store/h5vyjlmllyvcqsbq89gs06i09j1l9gm1-cabal2nix-hs.drv'...
installing
error: creating directory '/nix/var': Permission denied
error: creating directory '/nix/var': Permission denied
** need a revision for VCS when the hash is given. skipping.
** need a revision for VCS when the hash is given. skipping.
** need a revision for VCS when the hash is given. skipping.
** need a revision for VCS when the hash is given. skipping.
cabal2nix: user error (Failed to fetch source. Does this source exist? Source {sourceUrl = "/nix/store/fgiafw1caz7bnqwy7lrp6rg076z5n19s-hs", sourceRevision = "", sourceHash = Guess "", sourceCabalDir = ""})
note: keeping build directory '/tmp/nix-build-cabal2nix-hs.drv-7'
builder for '/nix/store/h5vyjlmllyvcqsbq89gs06i09j1l9gm1-cabal2nix-hs.drv' failed with exit code 1
error: while evaluating anonymous function at /home/teto/mptcpnetlink/shell-develop.nix:5:1, called from undefined position:
while evaluating 'developPackage' at /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:207:7, called from /home/teto/mptcpnetlink/shell-develop.nix:10:12:
while evaluating anonymous function at /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:210:20, called from /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:218:34:
while evaluating 'callCabal2nix' at /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:180:32, called from /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:213:9:
while evaluating 'overrideCabal' at /home/teto/nixpkgs/pkgs/development/haskell-modules/lib.nix:37:24, called from /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:190:8:
while evaluating 'callPackageKeepDeriver' at /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:156:33, called from /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:190:23:
while evaluating 'overrideCabal' at /home/teto/nixpkgs/pkgs/development/haskell-modules/lib.nix:37:24, called from /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:157:5:
while evaluating 'callPackage' at /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:115:22, called from /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:157:20:
while evaluating 'callPackageWithScope' at /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:75:37, called from /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:115:28:
while evaluating 'makeOverridable' at /home/teto/nixpkgs/lib/customisation.nix:67:24, called from /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:98:8:
while evaluating 'drvScope' at /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:88:18, called from /home/teto/nixpkgs/lib/customisation.nix:69:12:
build of '/nix/store/h5vyjlmllyvcqsbq89gs06i09j1l9gm1-cabal2nix-hs.drv' failed
and the error is not that clear, why would it try to create /nix/var ?
the hs.cabal file contains:
name: netlink-pm
version: 1.0.0
license: GPL-3
license-file: LICENSE
cabal-version: >= 1.18
build-type: Simple
executable project1
build-depends: base < 5, netlink
main-is: daemon.hs
default-language: Haskell2010
"x86_64-linux"
Linux 4.14.24, NixOS, 18.09.git.31145cb (Jellyfish)
yes
yes
nix-env (Nix) 2.0.4
/home/teto/nixpkgs
I can't reproduce this.
@mpickering thanks for trying.
I tried on upstream nixos-unstable with the same result. My haskell overlay just consists in zeromq4-haskell = prev.haskell.lib.dontCheck hprev.zeromq4-haskell;
so I doubt it's responsible for the error.
You might be able to reproduce by cloning https://github.com/teto/netlink_pm and running nix-shell shell-develop.nix
in the root folder. This repository is a huge mess as I try to convert a python script in haskell and learning about the haskell/nix quirks.
I can reproduce this with
{ pkgs ? import <nixpkgs> {} }:
pkgs.haskellPackages.developPackage {
root = ./emptydir; # this directory does not contain an emptydir.cabal
}
Note that your hs.cabal is a symlink to a file in /home/teto.
thanks !
hs.cabal is a symlink towards /home/teto/mptcpnetlink/hs/netlink-pm.cabal, ie, the netlink-pm.cabal in the same folder (https://github.com/teto/netlink_pm/blob/new/hs/netlink-pm.cabal). Depending on the tool (I don't remember if it's cabal/stack or another one), the name of the .cabal file must adopt different conventions. Either way, I am not sure why developPackage has this constraint. Wouldn't it be possible to search for a *.cabal and warn if there are several.
The symlink is valid
$ head /home/teto/mptcpnetlink/hs/hs.cabal
name: netlink-pm
version: 1.0.0
license: GPL-3
license-file: LICENSE
cabal-version: >= 1.18
build-type: Simple
executable project1
build-depends: base < 5, netlink
main-is: daemon.hs
but it's cool you could reproduce it with an empty dir.
The symlink is valid
But it's not dereferenced during import to the store.
{ pkgs ? import <nixpkgs> {} }:
pkgs.stdenv.mkDerivation {
name = "test";
version = "1";
src = ./.;
phases = [ "installPhase" ];
installPhase = ''
ls -l $src/symlink
cp $src/symlink $out; # symlink points to a file outside ./
'';
}
results in
these derivations will be built:
/nix/store/1gwl1220gfd5i4b7vzdwwyvqsrzllarr-test.drv
building '/nix/store/1gwl1220gfd5i4b7vzdwwyvqsrzllarr-test.drv'...
installing
lrwxrwxrwx 7 nobody nogroup 26 Jan 1 1970 /nix/store/64ycv3s7a5qhick3bhknnlm18q13q92x-emptydir/symlink -> /home/sarah/scratch/target
cp: cannot stat '/nix/store/64ycv3s7a5qhick3bhknnlm18q13q92x-emptydir/symlink': No such file or directory
Or, without the sandbox but still using normal nixbld isolation
these derivations will be built:
/nix/store/1gwl1220gfd5i4b7vzdwwyvqsrzllarr-test.drv
building '/nix/store/1gwl1220gfd5i4b7vzdwwyvqsrzllarr-test.drv'...
installing
lrwxrwxrwx 7 root root 26 Jan 1 1970 /nix/store/64ycv3s7a5qhick3bhknnlm18q13q92x-emptydir/symlink -> /home/sarah/scratch/target
cp: cannot stat '/nix/store/64ycv3s7a5qhick3bhknnlm18q13q92x-emptydir/symlink': Permission denied
right, thanks for investigating this. I hadn't thought about it because hs.cabal was originally a real file and I had (a different) problems. I replaced it iwth a hardlink and it seems fine (hell there are other haskell errors but I've gotten used to override everything).
This gave me a hunch I was at fault user error (Failed to fetch source. Does this source exist? Source {sourceUrl = "/nix/store/fgiafw1caz7bnqwy7lrp6rg076z5n19s-hs"
but ... well I have no excuse :'(
No problem! :) The error message isn't exactly very clear, and could be worth improving, if you want to file an issue! :)
I got this error for a different reason.
I had my Haskell package named differently (e.g. nix-batch
) from the directory it was in (e.g. nix-batch-hs
)
I read the code and realised it expects the directory to be named the same. In my case I just renamed the directory.
name ? builtins.baseNameOf root
Ugh, such code shouldn't exist :)
So what happens is:
1) developPackage
gets passed root = ./.
2) name
is determined by it's parent directory name (which will be different as it's user specific)
3) cabal2nix
can't find the cabal file so it falls back to git and other fetchers
Thank you for your contributions.
This has been automatically marked as stale because it has had no activity for 180 days.
If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.
Here are suggestions that might help resolve this more quickly:
Most helpful comment
Ugh, such code shouldn't exist :)
So what happens is:
1)
developPackage
gets passedroot = ./.
2)
name
is determined by it's parent directory name (which will be different as it's user specific)3)
cabal2nix
can't find the cabal file so it falls back to git and other fetchers