I have this in my shell config:
nix-load() {
local s=""
for attr in "$@"; do
s="$s nixpkgs#$attr"
done
paths="$(nix build --no-link --print-out-paths $s)"
for p in $paths; do
export PATH="$p/bin:$PATH"
done
}
Example: nix-load ffmpeg adds ffmpeg to the current shell’s PATH.
Note that this is equivalent to nix shell, not nix-shell. This means it only adds things to PATH. It doesn’t run stdenv setup hooks like nix-shell -p does.