Jump to content

Nix-ld

From NixOS Wiki
Revision as of 22:20, 22 May 2025 by TobiasBora (talk | contribs) (Created page with "== Nix-ld == Nix-ld is a module that is really practical to enable to have a more "traditional" experience in NixOS by recreating the loaders like `/lib/ld-linux.so.2`, needed to run any executable that is not patched by nix. It is not needed when installing regular packages "the nix way", but it is really handy to quickly test a binary not packaged for nix, or when developing, for instance in javascript/nodejs, since these languages often pre-download many binaries. To...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Nix-ld

Nix-ld is a module that is really practical to enable to have a more "traditional" experience in NixOS by recreating the loaders like `/lib/ld-linux.so.2`, needed to run any executable that is not patched by nix. It is not needed when installing regular packages "the nix way", but it is really handy to quickly test a binary not packaged for nix, or when developing, for instance in javascript/nodejs, since these languages often pre-download many binaries.

To enable it, you just need to put in your /etc/nixos/configuration.nix the following:

  programs.nix-ld = {
    enable = true;
    libraries = with pkgs; [
      ## Put here any library that is required when running a package
      ## ...
      ## Uncomment if you want to use the libraries provided by default in the steam distribution
      ## (quite exhaustive)
      ## https://github.com/NixOS/nixpkgs/issues/354513
      # (pkgs.runCommand "steamrun-lib" {} "mkdir $out; ln -s ${pkgs.steam-run.fhsenv}/usr/lib64 $out/lib")
    ];
  };
  ## Uncomment if you used steamrun's libraries
  # nixpkgs.config.allowUnfree = true;