From 7da7d567a0bbdc471d773ef2fce171c3391aee53 Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Tue, 6 Feb 2024 14:02:26 +0300 Subject: [PATCH] Nix : Use flake.nix in current dir for shell. --- .config/bash/module/Nix.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.config/bash/module/Nix.sh b/.config/bash/module/Nix.sh index e53ecfa..eca6460 100644 --- a/.config/bash/module/Nix.sh +++ b/.config/bash/module/Nix.sh @@ -60,13 +60,17 @@ function nix_clean() { _is_root && nix-store --gc } -# Spawn shell with specified nix environment. `Main` is default. +# Spawn shell with specified nix environment. +# Uses flake.nix in current dir by default. # Usage: nix_shell [NAME] function nix_shell() { local name="${1,,}" - [[ "${name}" = "" ]] && name="main" - NIX_SHELL="${name}" nix develop -f ~/.config/linux/shell/"${name^}".nix + if [[ "${name}" = "" ]]; then + NIX_SHELL=$(parse_alnum "${PWD##*/}") nix develop -f ./flake.nix + else + NIX_SHELL="${name}" nix develop -f ~/.config/linux/shell/"${name^}".nix + fi } alias shell="nix_shell"