Pure build of npm package

I’m trying to build a flox package for the FINOS CALM CLI npm package. This is my first time trying to do a build so I’m probably missing something, but based on the Flox npm docs and manifest build docs, I’ve come up with this manifest:

# Flox manifest version managed by Flox CLI
version = 1

[install]
nodejs_24.pkg-path = "nodejs_24"

[build.deps]
command = '''
  npm install @finos/calm-cli@1.23.3
  npm prune
  mkdir -p $out/bin
  cp -r ./node_modules $out/
  cp ./node_modules/.bin/calm $out/bin
'''

[build.calm-cli]
command = """
  mkdir -p $out/bin
  cp -r ${deps}/bin/calm $out/bin/
  cp -r ${deps}/node_modules $out/
"""
sandbox = "pure"

The “deps” build works fine (and if I remove the calm-cli section then the whole build succeeds), but the calm-cli “pure” build fails with a gazillion “permission denied failures”:

...
Completed build of deps-0.0.0 in local mode

Rendering calm-cli build script to /tmp/894cc421/calm-cli/build.bash
/nix/store/xs8scz9w9jp4hpqycx3n3bah5y07ymgj-coreutils-9.8/bin/comm -23 <(/nix/store/zb0vf5gnnqzb8grhnivsggi8mjyg8fha-git-minimal-2.51.0/bin/git ls-files -c | /nix/stor
e/xs8scz9w9jp4hpqycx3n3bah5y07ymgj-coreutils-9.8/bin/sort) <(/nix/store/zb0vf5gnnqzb8grhnivsggi8mjyg8fha-git-minimal-2.51.0/bin/git ls-files -d | /nix/store/xs8scz9w9j
p4hpqycx3n3bah5y07ymgj-coreutils-9.8/bin/sort) > /tmp/894cc421/calm-cli/src-list
Building calm-cli-0.0.0 in Nix sandbox (pure) mode
this derivation will be built:
  /nix/store/d8kabbdp3hgh7x0xxcicbppbda2h87zj-calm-cli-0.0.0.drv
building '/nix/store/d8kabbdp3hgh7x0xxcicbppbda2h87zj-calm-cli-0.0.0.drv'...
calm-cli> ---
calm-cli> Input checksums:
calm-cli> 1276481102f218c981e0324180bafd9f  /nix/store/l9h3r8h1xzxi4w2ldz1jl7h3yygzskd3-src.tar
calm-cli> e5998e1cf44c1c3abe0f014d73b26a6c  /nix/store/xfwvg0698mh1pn66dmshsrbgg31ck4vi-build.bash
calm-cli> 1cb0c6c747b78bd6b7e1f1b80211f0cb  /nix/store/y80glhgcs21w0h9yh2q3cncqgzcdd67j-buildCache.tar
calm-cli> ---
calm-cli> 00:00:00.003076 + mkdir -p /nix/store/czx9mhqbpvpigjh6479y0kfjhh3jkr3n-calm-cli-0.0.0/bin
calm-cli> 00:00:00.004910 + cp -r /nix/store/agm625pg4c2wnjgk9a13vy40d1nz2jxz-deps-0.0.0/bin/calm /nix/store/czx9mhqbpvpigjh6479y0kfjhh3jkr3n-calm-cli-0.0.0/bin/
calm-cli> 00:00:00.006584 + cp -r /nix/store/agm625pg4c2wnjgk9a13vy40d1nz2jxz-deps-0.0.0/node_modules /nix/store/czx9mhqbpvpigjh6479y0kfjhh3jkr3n-calm-cli-0.0.0/
calm-cli> mv: cannot remove '/nix/store/czx9mhqbpvpigjh6479y0kfjhh3jkr3n-calm-cli-0.0.0/node_modules/v8-compile-cache-lib/v8-compile-cache.d.ts': Permission denied
calm-cli> mv: cannot remove '/nix/store/czx9mhqbpvpigjh6479y0kfjhh3jkr3n-calm-cli-0.0.0/node_modules/v8-compile-cache-lib/package.json': Permission denied
calm-cli> mv: cannot remove '/nix/store/czx9mhqbpvpigjh6479y0kfjhh3jkr3n-calm-cli-0.0.0/node_modules/v8-compile-cache-lib/v8-compile-cache.js': Permission denied
calm-cli> mv: cannot remove '/nix/store/czx9mhqbpvpigjh6479y0kfjhh3jkr3n-calm-cli-0.0.0/node_modules/v8-compile-cache-lib/LICENSE': Permission denied
calm-cli> mv: cannot remove '/nix/store/czx9mhqbpvpigjh6479y0kfjhh3jkr3n-calm-cli-0.0.0/node_modules/v8-compile-cache-lib/README.md': Permission denied
calm-cli> mv: cannot remove '/nix/store/czx9mhqbpvpigjh6479y0kfjhh3jkr3n-calm-cli-0.0.0/node_modules/v8-compile-cache-lib/CHANGELOG.md': Permission denied
calm-cli> mv: cannot remove '/nix/store/czx9mhqbpvpigjh6479y0kfjhh3jkr3n-calm-cli-0.0.0/node_modules/ts-node/tsconfig.schema.json': Permission denied

Any suggestions as to what I’m doing wrong?

Flox 1.7.8 on Ubuntu 24.04.3 on WSL 2.6.3.0.

FYI, same behaviour with 1.8.0.

Good spot! That was my mistake, patch on its way in fix: don't cross filesystem boundaries renaming $out by limeytexan · Pull Request #3839 · flox/flox · GitHub .

In the meantime, try making this modification to the [build.calm-cli] command as a workaround:

diff --git a/.flox/env/manifest.toml b/.flox/env/manifest.toml
index 0240745..c5a3c4c 100644
--- a/.flox/env/manifest.toml
+++ b/.flox/env/manifest.toml
@@ -18,6 +18,7 @@ command = """
   mkdir -p $out/bin
   cp -r ${deps}/bin/calm $out/bin/
   cp -r ${deps}/node_modules $out/
+  find $out -type d -exec chmod +w {} ';'
 """
 sandbox = "pure"

Thanks for the bug report! The fix for this bug should be included in the next release.

That worked, thank you!

1 Like