How to actually use a packages optional features?

I want to use the program inxi from nix-shell, but it’s broken by default.

[davidak@gaming:~]$ nix run nixpkgs.inxi -c inxi -G
Graphics:  Device-1: Advanced Micro Devices [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] driver: amdgpu 
           v: kernel 
           Display: x11 server: X.org 1.20.13 driver: loaded: amdgpu note: n/a (using device driver) 
           resolution: <missing: xdpyinfo> 
           Message: Unable to show advanced data. Required tool glxinfo missing.

There are errors from missing dependencies, but they are actually in the package definition. It’s just not accessible.

So, how to actually use the package?

There seem to be no documentation in search.nixos.org, nixpkgs manual, nix run --help, this forum or nixos.wiki.

I tried this, but it does not do anything:

[davidak@gaming:~]$ nix run nixpkgs.inxi --arg withRecommends true -c inxi -G
Graphics:  Device-1: Advanced Micro Devices [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] driver: amdgpu 
           v: kernel 
           Display: x11 server: X.org 1.20.13 driver: loaded: amdgpu note: n/a (using device driver) 
           resolution: <missing: xdpyinfo> 
           Message: Unable to show advanced data. Required tool glxinfo missing.

Does it even make sense that a package is broken by default?

1 Like

You can override it:

nix-shell -p ‘inxi.override { withRecommends = true; }’ --run ‘inxi -G’

3 Likes

That does work. Thanks!

What about nix run?

What about nix run?

I’m sure there’s a way to do that too with nix run. Doesn’t man nix-run reveal anything?