home: direnv: refactor option handling

This will make it easier to add more options.
This commit is contained in:
Bruno BELANYI 2023-09-05 11:10:01 +00:00
parent 6ba7a63b25
commit ac93cb0ac8

View file

@ -11,10 +11,21 @@ use_pkgs() {
local DEFAULT_FLAKE="${DIRENV_DEFAULT_FLAKE:-nixpkgs}" local DEFAULT_FLAKE="${DIRENV_DEFAULT_FLAKE:-nixpkgs}"
# Allow changing the default flake through a command line switch # Allow changing the default flake through a command line switch
if [ "$1" = "-f" ] || [ "$1" = "--flake" ]; then while true; do
DEFAULT_FLAKE="$2" case "$1" in
shift 2 -f|--flake)
fi DEFAULT_FLAKE="$2"
shift 2
;;
--)
shift
break
;;
*)
break
;;
esac
done
# Allow specifying a full installable, or just a package name and use the default flake # Allow specifying a full installable, or just a package name and use the default flake