How to invoke `nix-shell -p` for packages not in Nixpkgs?

There are probably more, but I’m aware of at least two:

  • The “clean” way: add the package(s) to your system via overlay, where you can just reference them via -p <pkgname>
  • -p can accept an expression, so you can also do something ad hoc like: nix-shell -p '(callPackage (fetchTarball https://github.com/DavHau/mach-nix/tarball/3.0.2) {}).mach-nix'
3 Likes