Add only one executable to path from package

I would like to add only one program (resize) out of the many provided by busybox to my path. If I add busybox to my user’s packages configuration then it overshadows poweroff and reboot from systemd.

I could add xterm to packages and have nothing overlap, but I was trying to avoid adding everything required for X11 to a system that is only accessed over SSH or a serial terminal.

1 Like

You can make a package/derivation that uses busybox as a source or input and then copies the executable you need to that new package’s output.

Seems like something that might already have a convenience function in nixpkgs or elsewhere, but I don’t recall seeing it if so.

Something like:

pkgs.runCommand "busybox-resize" {} ''
  mkdir -p $out/bin
  ln ${lib.getExe pkgs.busybox "resize"} $out/bin/resize
''

Should do the trick.

1 Like