Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build error: Directory "/" is not accessible #7

Open
goertzenator opened this issue Dec 2, 2020 · 6 comments
Open

build error: Directory "/" is not accessible #7

goertzenator opened this issue Dec 2, 2020 · 6 comments

Comments

@goertzenator
Copy link

goertzenator commented Dec 2, 2020

I tried building this today on nixos-20.09 and it failed. I monkeyed with it briefly; adding unset HOME (ref purescript/spago#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

@tbenst
Copy link
Owner

tbenst commented Dec 2, 2020

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?

@goertzenator
Copy link
Author

That does in fact work!

@tbenst
Copy link
Owner

tbenst commented Dec 2, 2020

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

@goertzenator
Copy link
Author

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 having spago.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.

@tbenst
Copy link
Owner

tbenst commented Dec 2, 2020 via email

@goertzenator
Copy link
Author

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/
    '';
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants