I’m trying to build a stack project using haskell.nix and it requires stack-to-nix to be called during build time to generate nix derivations, but calling stack-to-nix requires internet access since it needs to clone github repos. I’m 100% sure that this is pure.
Here are the errors I got:
builder for '/nix/store/8w25s7dxlzknlg4rkar0iwd6jlasj48d-source-stack-to-nix-pkgs.drv' failed with exit code 1; last 6 log lines:
error: creating directory '/nix/var': Permission denied
Initialized empty Git repository in /build/git-checkout-tmp-kZWOiIWv/shake-fb3859d/.git/
fatal: unable to access 'https://github.com/wz1000/shake.git/': Could not resolve host: github.com
fatal: unable to access 'https://github.com/wz1000/shake.git/': Could not resolve host: github.com
Unable to checkout fb3859dca2e54d1bbb2c873e68ed225fa179fbef from https://github.com/wz1000/shake.git.
stack-to-nix: nix-prefetch-hg: createProcess: runInteractiveProcess: exec: does not exist (No such file or directory)
[0 built (1 failed), 0.0 MiB DL]
error: while evaluating anonymous function at /home/poscat/Projects/Nix/hls-nix/hls.nix:1:1
You can disable sandboxing in your /etc/nix/nix.conf/nix.useSandbox.
Though its better to not do that.
You should write your derivation in a way that it does not require online access at all. Perhaps provide all the stuff that is generated vi stack-to-nix via patches or another derivation?
Thx. The generated nix expressions are really large and I’d rather not to generate them beforehand. Would it be possible to temporarily disable sandbox?
Is the output of stack-to-nix deterministic? If so you can use a fixed-output derivation, which is allowed network access even while sandboxed as long as the output matches the hash (this is how stuff like fetchGitHub work).
trace: To make this a fixed-output derivation but not materialized, set `stack-sha256` to the output of /nix/store/k5g06sbk1dd3zcxcxsja0xvyjq1r8z0q-calculateSha
trace: To materialize the output entirely, pass a writable path as the `materialized` argument and pass that path to /nix/store/p1h3zhsbcd2mqsvzzn3sa2ldd3sfq23i-generateMaterialized
builder for '/nix/store/8w25s7dxlzknlg4rkar0iwd6jlasj48d-source-stack-to-nix-pkgs.drv' failed with exit code 1; last 10 log lines:
remote: Total 288 (delta 2), reused 78 (delta 2), pack-reused 0
Receiving objects: 100% (288/288), 686.64 KiB | 3.43 MiB/s, done.
Resolving deltas: 100% (2/2), done.
From https://github.com/wz1000/shake
* branch no-scheduler -> FETCH_HEAD
* [new branch] no-scheduler -> origin/no-scheduler
Switched to a new branch 'fetchgit'
removing `.git'...
error: cannot open connection to remote store 'daemon': reading from file: Connection reset by peer
stack-to-nix: nix-prefetch-hg: createProcess: runInteractiveProcess: exec: does not exist (No such file or directory)
[0 built (1 failed)]
I tried to build with sandbox turned off, git clone succeeded but It still failed, not sure why tho…
In general, the haskell.nix stuff should not require sandboxing turned off. My guess is that your nix code is incorrect.
Could you share your derivations using haskell.nix?
I feel like I heard someone complaining at ZuriHac this weekend that the documentation for stack based builds for Haskell.nix needed updating or something.
Oops I forgot to mention I fixed it by adding “.git” to the url, thanks for verifying that it builds. I think that was a (minor) bug of the haskell.nix library.