nixos - nix-shell 错误 - mkdir : cannot create directory '/nix/store/...' : Read-only file system

标签 nixos

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

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

通过 nix-build 运行时, 这段代码没问题,但是当用 nix-shell 运行时我无法创建 $out运行时的目录 configurePhase
mkdir: cannot create directory '/nix/store/...': Read-only file system

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

最佳答案

这是因为 $out指向 /nix/store/...以只读方式安装。

Eelco Dolstra pointed ,至少有两种方法可以解决这个问题:

  • 不要创建 $outconfigurePhase ,在 installPhase 中进行反而。
  • 套装$out到一些不同的值。

  • 您可以设置 $out变量与
    nix-shell --command "export out=/tmp/foo; return"
    

    关于nixos - nix-shell 错误 - mkdir : cannot create directory '/nix/store/...' : Read-only file system,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31559303/

    相关文章:

    x11 - 使用 LightDM + XMonad 在 NixOS 上进行 DPI 缩放

    zsh - NixOS 之外的 Nix 配置

    emacs - 如何在 Nixos 中的 Spacemacs 范围内添加其他软件包?

    nix - 如何导入 nixos 配置并将其与 nixops 部署表达式合并

    c - 将 linenoise 库添加到 nixpkgs

    linux - 如何在 configuration.nix 中添加 linux 配置

    nix - <nixpkgs> 字符串/值在 Nix 中是什么意思?

    haskell - 如何将包添加到 cabal2nix 生成的 `env` ?

    linux - 使用 nix-shell 或 nix shell 在 Linux 64 上运行 MacOS sed

    docker - 我可以通过 dockerTools.buildImage 制作 docker 镜像并使用 nixos 配置进行配置吗