How to use a system-imported executable in a script?

I’m currently trying to use nvidia-smi in a root script. The issue is that its not in nixpkgs, its from one of the virtualization options ( probably graphics.nvidia.open = true ). How would I go about importing it in a script, because right now its just crashing with “127 not found”


"passthrough.sh" = pkgs.writeShellScript "passthrough.sh" ''
    ${pkgs.nvidia-smi}/bin/nvidia-smi
    exit $("nvidia-smi") 
  '';
};
`

You should be able to get it from config.hardware.nvidia.package, I think.

Good thought, but it would not appear so. Most of the other stuff is there (drivers)

Ah, I was close. Try config.hardware.nvidia.package.settings. Seems it’s included as a passthru. EDIT: nvm, that’s nvidia-settings, not nvidia-smi.

On my system, nvidia-smi is there if I do a nix build of my config.hardware.nvidia.package.bin.

looks like it appears in the store ending with nvidia-x11. just have no idea how to get to it

I do (lib.getBin config.hardware.nvidia.package) in my config get the package containing nvidia-smi. Adding “/bin/nvidia-smi” should work.

A simpler equivalent would be

lib.getExe' config.hardware.nvidia.package "nvidia-smi"
5 Likes