purescript-nix-example
purescript-nix-example copied to clipboard
build error: Directory "/" is not accessible
I tried building this today on nixos-20.09 and it failed. I monkeyed with it briefly; adding unset HOME
(ref https://github.com/purescript/spago/issues/380) gets it past this first error but then that just leads to additional errors.
shrinking /nix/store/d8jz92pakqb6x5m1m8qqyydk1yddkbx5-purescript-nix-example/libexec/purescript-nix-example/node_modules/deasync/bin/linux-x64-node-9/deasync.node
shrinking /nix/store/d8jz92pakqb6x5m1m8qqyydk1yddkbx5-purescript-nix-example/libexec/purescript-nix-example/node_modules/deasync/bin/linux-x64-node-12/deasync.node
strip is /nix/store/p792j5f44l3f0xi7ai5jllwnxqwnka88-binutils-2.31.1/bin/strip
stripping (with command strip and flags -S) in /nix/store/d8jz92pakqb6x5m1m8qqyydk1yddkbx5-purescript-nix-example/libexec /nix/store/d8jz92pakqb6x5m1m8qqyydk1yddkbx5-purescript-nix-example/bin
patching script interpreter paths in /nix/store/d8jz92pakqb6x5m1m8qqyydk1yddkbx5-purescript-nix-example
checking for references to /build/ in /nix/store/d8jz92pakqb6x5m1m8qqyydk1yddkbx5-purescript-nix-example...
[error] Directory "/" is not accessible. Permissions {readable = True, writable = False, executable = False, searchable = True}
builder for '/nix/store/yhnhn7h0az1kma5i0l172i8d5c3ylvgw-purescript-nix-example.drv' failed with exit code 1
error: build of '/nix/store/yhnhn7h0az1kma5i0l172i8d5c3ylvgw-purescript-nix-example.drv' failed
As a sanity check, did you try adding the flag -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/d3f928282c0989232e425d26f0302120a8c7218b.tar.gz
to the build command?
That does in fact work!
Ok great. I hope with this repo is it should build for a long time despite the chaos of JavaScript/purescript.
But of course it’s nice to have latest features. It’s likely that spago just needs to be bumped since it’s pinned right now. I’ve been meaning to try https://github.com/justinwoo/easy-purescript-nix
I was able to make this work on current NixOS with spago-0.16:
- As previously mentioned, I have to
unset HOME
. -
spago
insists on touching the network to download the package file which fails inside a derivation. I was able to fake it out by downloading it by hand and havingspago.dhall
point to that instead. I also tried providing it a pre-populated cache but I could not make that work.
Tomorrow I will attempt to replace my use of spago bundle-app
with purs bundle
since spago is proving to be too much of a hassle.
Interesting. I’ve mostly worked inside the nix-shell, which should make life easier as network access is ok. Once you’ve generated the nix files then can use nix-build.
Using purs bundle
instead of spago bundle-app
worked perfectly for my project. My default.nix is below. Note that I've separated deps into their own derivation so they don't need to get rebuilt all the time which is a time saver for my particular work flow.
{pkgs, stdenv, runCommand, purescript}:
let
depSources = let
spagoPkgs = import ./spago-packages.nix {inherit pkgs;};
in
builtins.toString
(builtins.map
(x: ''"${x.outPath}/src/**/*.purs"'')
(builtins.attrValues spagoPkgs.inputs));
# cache deps in separate derivation
deps = runCommand "webui-deps" {buildInputs = [ purescript ];} ''
purs compile ${depSources}
tar -cf $out output
'';
in
stdenv.mkDerivation {
name = "webui";
src = ./.;
buildInputs = [ purescript ];
buildPhase = ''
tar -xf ${deps} # populate precompiled deps
purs compile "$src/**/*.purs" ${depSources}
purs bundle "output/*/*.js" --output index.js
'';
installPhase = ''
mkdir -p $out
cp -a css images index.js index.html $out/
'';
}