[英]Change nix-build's TMPDIR from shell.nix
I'm trying to use nix-shell
with a shell.nix
file to get a clean development environment but I don't know how to change the location of the temporary build directories.我正在尝试使用带有
shell.nix
文件的nix-shell
来获得一个干净的开发环境,但我不知道如何更改临时构建目录的位置。
The buildInputs
packages are built in /tmp
but this path doesn't have enough space and I get an error: [Errno 28] No space left on device
during the build. buildInputs
包是在/tmp
中构建的,但是这个路径没有足够的空间,我收到一个error: [Errno 28] No space left on device
。
I tried running nix-shell
with a modified TMPDIR
environment variable but it only affects the location of the nix-shell
temporary files.我尝试使用修改后的
TMPDIR
环境变量运行nix-shell
,但它只影响nix-shell
临时文件的位置。 The nix-build
files are still put in /tmp
. nix-build
文件仍然放在/tmp
中。
I also tried to export a new value for TMPDIR
in the shellHook
but it doesn't work.我还尝试在
shellHook
中为TMPDIR
导出一个新值,但它不起作用。
How can I change the TMPDIR
of nix-build
when it's started by nix-shell
?当
nix-shell
启动时,如何更改nix-build
的TMPDIR
?
Here's my shell.nix
:这是我的
shell.nix
:
let
pkgs = import <nixpkgs> {};
in
pkgs.mkShell {
name = "something";
buildInputs = with pkgs; [
python38
python38Packages.pytorchWithCuda
];
shellHook = ''
'';
}
I got the answer on the NixOS forum :我在 NixOS 论坛上得到了答案:
If this is a mutli-user install, you need to modify the Nix daemon's TMPDIR.
如果这是多用户安装,则需要修改 Nix 守护进程的 TMPDIR。
To do that on my system I created a /etc/systemd/system/nix-daemon.service.d/override.conf
with:为此,我在我的系统上创建了一个
/etc/systemd/system/nix-daemon.service.d/override.conf
:
[Service]
Environment=TMPDIR=/var/tmp/nix-daemon
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.