home: direnv: allow impure 'use pkgs'

This makes it easier to use non-free or insecure packages.
This commit is contained in:
Bruno BELANYI 2023-09-05 11:15:33 +00:00
parent ac93cb0ac8
commit 5926cd356d

View file

@ -9,6 +9,8 @@ use_pkgs() {
# Use user-provided default value, or fallback to nixpkgs
local DEFAULT_FLAKE="${DIRENV_DEFAULT_FLAKE:-nixpkgs}"
# Additional args that should be forwarded to `nix`
local args=()
# Allow changing the default flake through a command line switch
while true; do
@ -17,6 +19,10 @@ use_pkgs() {
DEFAULT_FLAKE="$2"
shift 2
;;
-i|--impure)
args+=(--impure)
shift
;;
--)
shift
break
@ -39,5 +45,5 @@ use_pkgs() {
done
# shellcheck disable=2154
direnv_load nix shell "${packages[@]}" --command "$direnv" dump
direnv_load nix shell "${args[@]}" "${packages[@]}" --command "$direnv" dump
}