Nix-shell error - mkdir: unable to create directory '/ nix / store / ...': read-only filesystem
I am using nix-shell
to debug my package. The configuration script looks like this:
configurePhase = ''
mkdir -p $out
...
'';
When run through nix-build
, this code is fine, but when run with, nix-shell
I cannot create directory $out
on startupconfigurePhase
mkdir: cannot create directory '/nix/store/...': Read-only file system
I understand why this is happening, but how do I fix it?
source to share
This is because it $out
points to /nix/store/...
which is mounted as read-only.
As Eelco Dolstra pointed out , there are two ways to fix this:
-
Don't build
$out
inconfigurePhase
, use insteadinstallPhase
. -
Set
$out
to a different value.
You can set a variable $out
with
nix-shell --command "export out=/tmp/foo; return"
source to share