Describe the bug
When trying to build a Haskell package I get
[sundials@CUDA:~/chebApprox]$ nix-build release.nix
building '/nix/store/h5d9w5vi3xv1mq4s2v5szsg2rkyimg6l-cabal2nix-accelerate-llvm.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/80i4d2d1kcw74dhm8l3ryc85ilzcy014-source", sourceRevision = "", sourceHash = Guess "\
", sourceCabalDir = ""})
builder for '/nix/store/h5d9w5vi3xv1mq4s2v5szsg2rkyimg6l-cabal2nix-accelerate-llvm.drv' failed with exit code 1
error: build of '/nix/store/h5d9w5vi3xv1mq4s2v5szsg2rkyimg6l-cabal2nix-accelerate-llvm.drv' failed
(use '--show-trace' to show detailed location information)
To Reproduce
Steps to reproduce the behavior:
git clone https://github.com/idontgetoutmuch/chebApprox.gitcd chebApproxnix-build bugReport.nixExpected behavior
I expect the Haskell package to build without error.
Metadata
Please run nix run nixpkgs.nix-info -c nix-info -m and paste the result.
[sundials@CUDA:~/chebApprox]$ nix run nixpkgs.nix-info -c nix-info -m
- system: `"x86_64-linux"`
- host os: `Linux 4.19.69, NixOS, 19.09.git.latest0 (Loris)`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.2.2`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
Other
Just in case someone can spot the problem at a glance here is the nix derivation
let
foo = self: super: {
haskell = super.haskell // { packageOverrides =
hself: hsuper: {
accelerate = super.haskell.lib.dontCheck (
hself.callCabal2nix "accelerate" (builtins.fetchGit {
url = "https://github.com/AccelerateHS/accelerate.git";
rev = "a7b685352330ebf7d8794aed64663a9ee92dcdab";
}) {}
);
# accelerate-llvm = super.haskell.lib.dontCheck (hself.callPackage /home/sundials/accelerate-llvm/accelerate-llvm { });
accelerate-llvm = super.haskell.lib.dontCheck (
hself.callCabal2nix "accelerate-llvm" (builtins.fetchGit {
url = "https://github.com/AccelerateHS/accelerate-llvm";
rev = "1680d3fdb34073d2cc25c265968a695525bc1bf2";
}) { subpath = "accelerate-llvm"; }
);
# accelerate-llvm-ptx = super.haskell.lib.dontCheck (hself.callPackage /home/sundials/accelerate-llvm/accelerate-llvm-ptx { });
accelerate-llvm-ptx = super.haskell.lib.dontCheck (
hself.callCabal2nix "accelerate-llvm-ptx" (builtins.fetchGit {
url = "https://github.com/AccelerateHS/accelerate-llvm";
rev = "1680d3fdb34073d2cc25c265968a695525bc1bf2";
}) { subpath = "accelerate-llvm-ptx"; }
);
# accelerate-llvm-native = super.haskell.lib.dontCheck (hself.callPackage /home/sundials/accelerate-llvm/accelerate-llvm-native { });
accelerate-llvm-native = super.haskell.lib.dontCheck (
hself.callCabal2nix "accelerate-llvm-native" (builtins.fetchGit {
url = "https://github.com/AccelerateHS/accelerate-llvm";
rev = "1680d3fdb34073d2cc25c265968a695525bc1bf2";
}) { subpath = "accelerate-llvm-native"; }
);
accelerate-fft = super.haskell.lib.dontCheck (
hself.callCabal2nix "accelerate-fft" (builtins.fetchGit {
url = "https://github.com/AccelerateHS/accelerate-fft";
rev = "24de1074001142bf02009ed36479dc9e8e045c61";
}) {}
);
lens-accelerate = super.haskell.lib.dontCheck (
hself.callCabal2nix "lens-accelerate" (builtins.fetchGit {
url = "https://github.com/tmcdonell/lens-accelerate";
rev = "b74eb8098735b1ad6cff3c5655af03d3f29b9f8e";
}) {}
);
};
};
};
in
let
pkgs = import <nixpkgs> {
config.allowUnfree = true;
config.allowBroken = false;
overlays = [ foo ];
};
in
let
pkgs = import <nixpkgs> {
config.allowUnfree = true;
config.allowBroken = false;
overlays = [ foo ];
};
in
pkgs.haskellPackages.callPackage ./default.nix {
accelerate = pkgs.haskellPackages.accelerate;
accelerate-llvm-native = pkgs.haskellPackages.accelerate-llvm-native;
accelerate-fft = pkgs.haskellPackages.accelerate-fft;
lens-accelerate = pkgs.haskellPackages.lens-accelerate;
}
If I clone the repos and run cabal2nix . --subpath <name> and then modify the derivation as in the snippet below then everything builds
accelerate-llvm = super.haskell.lib.dontCheck (hself.callPackage /home/sundials/accelerate-llvm/accelerate-llvm { });
# accelerate-llvm = super.haskell.lib.dontCheck (
# hself.callCabal2nix "accelerate-llvm" (builtins.fetchGit {
# url = "https://github.com/AccelerateHS/accelerate-llvm";
# rev = "1680d3fdb34073d2cc25c265968a695525bc1bf2";
# }) { subpath = "accelerate-llvm"; }
# );
accelerate-llvm-ptx = super.haskell.lib.dontCheck (hself.callPackage /home/sundials/accelerate-llvm/accelerate-llvm-ptx { });
# accelerate-llvm-ptx = super.haskell.lib.dontCheck (
# hself.callCabal2nix "accelerate-llvm-ptx" (builtins.fetchGit {
# url = "https://github.com/AccelerateHS/accelerate-llvm";
# rev = "1680d3fdb34073d2cc25c265968a695525bc1bf2";
# }) { subpath = "accelerate-llvm-ptx"; }
# );
accelerate-llvm-native = super.haskell.lib.dontCheck (hself.callPackage /home/sundials/accelerate-llvm/accelerate-llvm-native { });
# accelerate-llvm-native = super.haskell.lib.dontCheck (
# hself.callCabal2nix "accelerate-llvm-native" (builtins.fetchGit {
# url = "https://github.com/AccelerateHS/accelerate-llvm";
# rev = "1680d3fdb34073d2cc25c265968a695525bc1bf2";
# }) { subpath = "accelerate-llvm-native"; }
# );
@idontgetoutmuch I think the problem is with the call to callCabal2nix.
I don't think callCabal2nix uses the subpath argument. (I think those arguments are instead normal Haskell dep override arguments.)
There are two ways to fix this. The first, and easiest, is just to use the full path to the packages. Here's a diff from the current bugReport.nix file:
diff --git a/bugReport.nix b/bugReport.nix
index 5a698c3..ea9171f 100644
--- a/bugReport.nix
+++ b/bugReport.nix
@@ -10,24 +10,24 @@ let
);
# accelerate-llvm = super.haskell.lib.dontCheck (hself.callPackage /home/sundials/accelerate-llvm/accelerate-llvm { });
accelerate-llvm = super.haskell.lib.dontCheck (
- hself.callCabal2nix "accelerate-llvm" (builtins.fetchGit {
+ hself.callCabal2nix "accelerate-llvm" ((builtins.fetchGit {
url = "https://github.com/AccelerateHS/accelerate-llvm";
rev = "1680d3fdb34073d2cc25c265968a695525bc1bf2";
- }) { subpath = "accelerate-llvm"; }
+ }) + /accelerate-llvm) { }
);
# accelerate-llvm-ptx = super.haskell.lib.dontCheck (hself.callPackage /home/sundials/accelerate-llvm/accelerate-llvm-ptx { });
accelerate-llvm-ptx = super.haskell.lib.dontCheck (
- hself.callCabal2nix "accelerate-llvm-ptx" (builtins.fetchGit {
+ hself.callCabal2nix "accelerate-llvm-ptx" ((builtins.fetchGit {
url = "https://github.com/AccelerateHS/accelerate-llvm";
rev = "1680d3fdb34073d2cc25c265968a695525bc1bf2";
- }) { subpath = "accelerate-llvm-ptx"; }
+ }) + /accelerate-llvm-ptx) {}
);
# accelerate-llvm-native = super.haskell.lib.dontCheck (hself.callPackage /home/sundials/accelerate-llvm/accelerate-llvm-native { });
accelerate-llvm-native = super.haskell.lib.dontCheck (
- hself.callCabal2nix "accelerate-llvm-native" (builtins.fetchGit {
+ hself.callCabal2nix "accelerate-llvm-native" ((builtins.fetchGit {
url = "https://github.com/AccelerateHS/accelerate-llvm";
rev = "1680d3fdb34073d2cc25c265968a695525bc1bf2";
- }) { subpath = "accelerate-llvm-native"; }
+ }) + /accelerate-llvm-native) {}
);
accelerate-fft = super.haskell.lib.dontCheck (
hself.callCabal2nix "accelerate-fft" (builtins.fetchGit {
With this change, the callCabal2nix calls should at least work now. I didn't try actually compiling the rest, but this should hopefully get you a little further.
Another solution is to use callCabal2nixWithOptions and explicitly pass the --subpath option like you do when you run it by hand.
@cdepillabout - the first solution works thanks very much - I did wonder about callCabal2nixWithOptions but was unsure what the syntax would be. Now I am on to the next problem (really - the projects all have a symbolic link to the LICENSE file and building via nix seems not to be able to cope with this).
Anyhow thanks once again :)
Aha - this is why I wanted to use callCabal2nix https://github.com/NixOS/nixpkgs/issues/42550#issuecomment-400687396
Now everything works
accelerate-llvm = super.haskell.lib.dontCheck (
hself.callCabal2nixWithOptions "accelerate-llvm" (builtins.fetchGit {
url = "https://github.com/AccelerateHS/accelerate-llvm";
rev = "1680d3fdb34073d2cc25c265968a695525bc1bf2";
}) "--subpath accelerate-llvm" { }
);
accelerate-llvm-ptx = super.haskell.lib.dontCheck (
hself.callCabal2nixWithOptions "accelerate-llvm-ptx" (builtins.fetchGit {
url = "https://github.com/AccelerateHS/accelerate-llvm";
rev = "1680d3fdb34073d2cc25c265968a695525bc1bf2";
}) "--subpath accelerate-llvm-ptx" { }
);
accelerate-llvm-native = super.haskell.lib.dontCheck (
hself.callCabal2nixWithOptions "accelerate-llvm-native" (builtins.fetchGit {
url = "https://github.com/AccelerateHS/accelerate-llvm";
rev = "1680d3fdb34073d2cc25c265968a695525bc1bf2";
}) "--subpath accelerate-llvm-native" { }
);
Most helpful comment
Now everything works
accelerate-llvm = super.haskell.lib.dontCheck ( hself.callCabal2nixWithOptions "accelerate-llvm" (builtins.fetchGit { url = "https://github.com/AccelerateHS/accelerate-llvm"; rev = "1680d3fdb34073d2cc25c265968a695525bc1bf2"; }) "--subpath accelerate-llvm" { } ); accelerate-llvm-ptx = super.haskell.lib.dontCheck ( hself.callCabal2nixWithOptions "accelerate-llvm-ptx" (builtins.fetchGit { url = "https://github.com/AccelerateHS/accelerate-llvm"; rev = "1680d3fdb34073d2cc25c265968a695525bc1bf2"; }) "--subpath accelerate-llvm-ptx" { } ); accelerate-llvm-native = super.haskell.lib.dontCheck ( hself.callCabal2nixWithOptions "accelerate-llvm-native" (builtins.fetchGit { url = "https://github.com/AccelerateHS/accelerate-llvm"; rev = "1680d3fdb34073d2cc25c265968a695525bc1bf2"; }) "--subpath accelerate-llvm-native" { } );