This a post on my "Noframes" wiki.

BashAliasNixProfileBash

In my .bash_aliases, I have two functions for Nix currently:

alias nr=nixrun
nixrun() {
        what="$1"
        shift
        nix run nixpkgs'#'"$what" "$@"
}
proadd() {
        what="$1"
        shift
        nix profile add nixpkgs'#'"$what" "$@"
}
alias nsea=nix-search
alias nixsearch=nix-search

So I had a $0 rather than a $@ in my proadd(), and thus e.g. proadd gimp, rather than becoming

nix profile add nixpkgs#gimp

was becoming

nix profile add nixpkgs#gimp /run/current-system/sw/bin/bash

and erroring with a cryptic error that had me thinking for a month or so that uh, I guess everything accidentally provides bash and is ill-suited for being used in a profile rather than a normal config:

error: An existing package already provides the following file:

         "/nix/store/yisa2lg79zcvgk4ck4yr6r0lz6j63hs3-bash-interactive-5.3p9/bin/bash"

       This is the conflicting file from the new package:

         "/nix/store/v2jl30hf667kdg34f8g1rvzxy28s1gnk-home-manager-path/bin/bash"

       To remove the existing package:

         nix profile remove bash-interactive

       The new package can also be added next to the existing one by assigning a different priority.
       The conflicting packages have a priority of 5.
       To prioritise the new package:

         nix profile add /nix/store/v2jl30hf667kdg34f8g1rvzxy28s1gnk-home-manager-path --priority 4

       To prioritise the existing package:

         nix profile add /nix/store/v2jl30hf667kdg34f8g1rvzxy28s1gnk-home-manager-path --priority 6

I thought I can't use nix profile the way I'd want to! And the error didn't occur when I happened to not have my aliases loaded, or when I used the run alias instead, so I thought it is only the issue with some programs that are more related to shell usage/scripting — specifically, rcs and jj.