mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 14:49:14 +00:00
packages/nix-which: init
This commit is contained in:
parent
c031e42fd2
commit
7dccaa90e5
1 changed files with 27 additions and 0 deletions
27
nix/packages/by-name/nix-which/package.nix
Normal file
27
nix/packages/by-name/nix-which/package.nix
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
writeShellApplication,
|
||||
which,
|
||||
lib,
|
||||
}: let
|
||||
# Use this to not pollute the PATH inside
|
||||
# Otherwise nix-which which will be an edge case
|
||||
whichExe = "${lib.getExe which}";
|
||||
in
|
||||
writeShellApplication {
|
||||
name = "nix-which";
|
||||
text = ''
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Must provide exactly one argument, the package to be dereferenced"
|
||||
exit 1
|
||||
fi
|
||||
target="$1"
|
||||
|
||||
target="$(${whichExe} "$target")"
|
||||
echo "==> $target"
|
||||
|
||||
while [ -L "$target" ]; do
|
||||
target="$(readlink "$target")"
|
||||
echo "==> $target"
|
||||
done
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue