pkgs/nix-index: use cnf output similar to default NixOS one

This commit is contained in:
Wroclaw 2024-07-09 06:34:48 +02:00
parent e95279f45c
commit 28bf1a9a0d
2 changed files with 75 additions and 0 deletions

View file

@ -0,0 +1,66 @@
diff --git a/command-not-found.sh b/command-not-found.sh
index 5f30bad..3854297 100755
--- a/command-not-found.sh
+++ b/command-not-found.sh
@@ -73,51 +73,30 @@ EOF
else
if [ -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
-
-Or run it once with:
- nix shell $toplevel#$attrs -c $cmd ...
+The program '$cmd' is not in your PATH. You can make it available in an
+ephemeral shell by typing:
+ nix shell $toplevel#$attrs
EOF
else
>&2 cat <<EOF
-The program '$cmd' is currently not installed. You can install it
-by typing:
- nix-env -iA $toplevel.$attrs
-
-Or run it once with:
- nix-shell -p $attrs --run '$cmd ...'
+The program '$cmd' is not in your PATH. You can make it available in an
+ephemeral shell by typing:
+ nix-shell -p $attrs
EOF
fi
fi
;;
*)
>&2 cat <<EOF
-The program '$cmd' is currently not installed. It is provided by
-several packages. You can install it by typing one of the following:
-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"
- else
- >&2 echo " nix-env -iA $toplevel.$attr"
- fi
- done <<< "$attrs"
-
- >&2 cat <<EOF
-
-Or run it once with:
+The program '$cmd' is not in your PATH. You can make it available in an
+ephemeral shell by typing:
EOF
while read attr; do
if [ -e "$HOME/.nix-profile/manifest.json" ]; then
- >&2 echo " nix shell $toplevel#$attr -c $cmd ..."
+ >&2 echo " nix shell $toplevel#$attr"
else
- >&2 echo " nix-shell -p $attr --run '$cmd ...'"
+ >&2 echo " nix-shell -p $attr"
fi
done <<< "$attrs"
;;

View file

@ -0,0 +1,9 @@
{self, super, package }:
package.override {
nix-index-unwrapped = self.nix-index-unwrapped.overrideAttrs (oldAttrs: {
patches = oldAttrs.patches or [] ++ [
./cnfOutput.patch
];
});
}