Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions command-not-found.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ command_not_found_handle () {
The program '$cmd' is currently not installed. It is provided by
the package '$toplevel.$attrs', which I will now install for you.
EOF
if [ -e "$HOME/.nix-profile/manifest.json" ]; then
nix profile install $toplevel#$attrs
if [ -e "${XDG_STATE_HOME-$HOME/.local/state}/nix/profile" ] || [ -e "$HOME/.nix-profile/manifest.json" ]; then
nix profile add $toplevel#$attrs
else
nix-env -iA $toplevel.$attrs
fi
Expand All @@ -71,11 +71,11 @@ $cmd: command not found
EOF
fi
else
if [ -e "$HOME/.nix-profile/manifest.json" ]; then
if [ -e "${XDG_STATE_HOME-$HOME/.local/state}/nix/profile" ] || [ -e "$HOME/.nix-profile/manifest.json" ]; then
>&2 cat <<EOF
The program '$cmd' is currently not installed. You can install it
by typing:
nix profile install $toplevel#$attrs
nix profile add $toplevel#$attrs

Or run it once with:
nix shell $toplevel#$attrs -c $cmd ...
Expand All @@ -101,8 +101,8 @@ EOF
# ensure we get each element of attrs
# in a cross platform way
while read attr; do
if [ -e "$HOME/.nix-profile/manifest.json" ]; then
>&2 echo " nix profile install $toplevel#$attr"
if [ -e "${XDG_STATE_HOME-$HOME/.local/state}/nix/profile" ] || [ -e "$HOME/.nix-profile/manifest.json" ]; then
>&2 echo " nix profile add $toplevel#$attr"
else
>&2 echo " nix-env -iA $toplevel.$attr"
fi
Expand All @@ -114,7 +114,7 @@ Or run it once with:
EOF

while read attr; do
if [ -e "$HOME/.nix-profile/manifest.json" ]; then
if [ -e "${XDG_STATE_HOME-$HOME/.local/state}/nix/profile" ] || [ -e "$HOME/.nix-profile/manifest.json" ]; then
>&2 echo " nix shell $toplevel#$attr -c $cmd ..."
else
>&2 echo " nix-shell -p $attr --run '$cmd ...'"
Expand Down