【问题标题】:How do I set the ulimit in a nix build shell?如何在 nix 构建 shell 中设置 ulimit?
【发布时间】:2018-08-24 09:29:26
【问题描述】:

我正在尝试为 nix 安装 certbot 包,但每次测试都失败,因为测试达到了系统上的打开文件限制。我已经修改了 certbot 安装脚本,足以打印出 patchPhase 开头的 ulimit 并发现允许打开的文件的最大数量是 256。但是,在我正在执行 nix-shell 或 @ 的 shell 中987654323@,我的ulimit(硬软)设置为100000。

如何将该限​​制推广到 certbot 构建过程?我想避免试图弄清楚如何修改 certbot 使用的 python 构建脚本。

在 OSX 10.13 上运行 Bash shell。

【问题讨论】:

  • 您是在 nix-daemon 上运行构建还是安装了单用户 Nix?
  • 看起来像nix-daemon。这可以解释为什么事情没有传播。

标签: darwin ulimit nix


【解决方案1】:

certbot.nixpatchPhase 节中手动提高ulimit。事实证明,这种变化会传播到 certbot 构建脚本中的其余阶段。

  buildInputs = [ dialog ] ++ (with python2Packages; [ nose mock gnureadline ]);

  patchPhase = ''
    ulimit -n 8196
    substituteInPlace certbot/notify.py --replace "/usr/sbin/sendmail" "/run/wrappers/bin/sendmail"
    substituteInPlace certbot/util.py --replace "sw_vers" "/usr/bin/sw_vers"
  '';

  postInstall = ''

我会向nixpkgs提交补丁。

【讨论】:

  • 从同一个 shell 调用阶段。 ulimit 是一个内置的 shell,用于设置由子进程继承的进程设置。
猜你喜欢
  • 1970-01-01
  • 2016-12-05
  • 1970-01-01
  • 2022-10-25
  • 2017-07-19
  • 2012-10-26
  • 2016-02-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多