gpt4 book ai didi

ocaml - 如何正确使用 nix-shell 并避免 "dumping very large path"?

转载 作者:行者123 更新时间:2023-12-02 00:54:17 24 4
gpt4 key购买 nike

根据我的阅读内容(特别是 the wikithis blog post ),我提出了使用 nix-shell 加载的以下 default.nix :

with import <nixpkgs> {};

let emacs =
emacsWithPackages (p : [ p.tuareg ]);
in

stdenv.mkDerivation rec {
name = "env";

src = ./.;

# Customizable development requirements
buildInputs = [
pkgconfig
ocaml
ocamlPackages.merlin
ocamlPackages.findlib
ocamlPackages.lablgtk
ocamlPackages.camlp5_transitional
ncurses
emacs
];

# Customizable development shell setup
shellHook = ''
export PATH=`pwd`/bin:$PATH
'';
}

但它总是打印警告:

warning: dumping very large path (> 256 MiB); this may run out of memory

加载时间很长(启动后第一次调用 nix-shell 大约需要 45 秒,后续调用大约需要 2 秒)。

此消息的含义是什么?当我在Google上查找时,我发现了一些GitHub问题,但没有以外行人易于理解的方式表达。

我可以加快加载速度并删除此消息吗?在我看来,我做错了什么。

是否存在我可能不知道的关于编写此类开发环境的一般建议?

最佳答案

可能src属性(当前目录)非常大。 nix-shell 会在每次调用时将其复制到 Nix 存储,这可能不是您想要/需要的。解决方法是编写:

src = if lib.inNixShell then null else ./.;

(其中 lib 来自 Nixpkgs)。

这样,./. 将在您调用 nix-build 时被复制,但在您运行 nix-shell 时不会被复制。

关于ocaml - 如何正确使用 nix-shell 并避免 "dumping very large path"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39372157/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com