5

nix-shell用来调试我的包。配置脚本如下所示:

configurePhase = ''
  mkdir -p $out
  ...
'';

通过运行时nix-build,此代码是可以的,但是运行时nix-shell我无法$out在运行时创建目录configurePhase

mkdir: cannot create directory '/nix/store/...': Read-only file system

我明白为什么会发生这种情况,但是如何解决这个问题?

4

1 回答 1

5

This happens because $out points to /nix/store/... which is mounted as readonly.

As Eelco Dolstra pointed, there are at leasy two ways to fix this:

  • Don't create $out in configurePhase, do it in installPhase instead.

  • Set $out to some different value.

You can set $out variable with

nix-shell --command "export out=/tmp/foo; return"
于 2015-07-25T14:04:14.453 回答