介绍如何配置 nix-community/nix-ld 及 envfs 来让非 nixos 编译二进制文件能在 nixos 上正常运行。

programs = {
  nix-ld = {
    enable = true;
    # put whatever libraries you think you might need
    # nix-ld includes a strong sane-default as well
    # in addition to these
    libraries = with pkgs; [
      stdenv.cc.cc.lib
      zlib
    ];
  };
};
 
services = {
  envfs = {
    enable = true;
  };
};

另一种思路是使用 steam-run 运行: Node.js - NixOS Wiki