From ac93cb0ac8cd2ff4c0194bb0cf2d9aca1c34f758 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Tue, 5 Sep 2023 11:10:01 +0000 Subject: [PATCH] home: direnv: refactor option handling This will make it easier to add more options. --- home/direnv/lib/nix.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/home/direnv/lib/nix.sh b/home/direnv/lib/nix.sh index 2d40b20..b0c2dae 100644 --- a/home/direnv/lib/nix.sh +++ b/home/direnv/lib/nix.sh @@ -11,10 +11,21 @@ use_pkgs() { local DEFAULT_FLAKE="${DIRENV_DEFAULT_FLAKE:-nixpkgs}" # Allow changing the default flake through a command line switch - if [ "$1" = "-f" ] || [ "$1" = "--flake" ]; then - DEFAULT_FLAKE="$2" - shift 2 - fi + while true; do + case "$1" in + -f|--flake) + 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