diff --git a/.config/bash/module/Nix.sh b/.config/bash/module/Nix.sh index e3eb16c..652e162 100644 --- a/.config/bash/module/Nix.sh +++ b/.config/bash/module/Nix.sh @@ -1,23 +1,3 @@ -# Find Nix package path. -# Usage: nix_find -function nix_find() { - local IFS=$'\n' - local package="${1}" - - if [[ "${package}" = "" ]]; then - help find_nix - return 2 - fi - - local found=$(ls --classify /nix/store/ | grep "${package}".*/) - - if [[ "${found}" != "" ]]; then - echo "/nix/store/${found%/}" - else - false - fi -} - # Rebuild system. # Optionally force the hostname. # Usage: nix_rebuild [HOSTNAME] @@ -26,7 +6,7 @@ function nix_rebuild() { [[ "${target}" = "" ]] && target="${HOSTNAME}" cd ${HOME}/.config/linux/system - nixos-rebuild boot --flake .#${target} + nixos-rebuild boot --flake ".#${target}" cd - } @@ -37,19 +17,15 @@ function nix_switch() { local target="${1}" [[ "${target}" = "" ]] && target="${HOSTNAME}" - cd ${HOME}/.config/linux/system - nixos-rebuild switch --flake .#${target} + cd "${HOME}/.config/linux/system" + nixos-rebuild switch --flake ".#${target}" cd - } -# Update system. -# Optionally force the hostname. -# Usage: nix_update [HOSTNAME] +# Update system versions. +# Usage: nix_update function nix_update() { - local target="${1}" - [[ "${target}" = "" ]] && target="${HOSTNAME}" - - cd ${HOME}/.config/linux/system + cd "${HOME}/.config/linux/system" nix flake update cd - } @@ -64,13 +40,10 @@ function nix_clean() { # Uses flake.nix in current dir by default. # Usage: nix_shell [NAME] function nix_shell() { - local name="${1,,}" + local target="${1}" + [[ "${target}" = "" ]] && target="default" - if [[ "${name}" = "" ]]; then - NIX_SHELL=$(parse_alnum "${PWD##*/}") nix develop - else - NIX_SHELL="${name}" nix develop -f ~/.config/linux/shell/"${name^}".nix - fi + NIX_SHELL="${target}" nix develop ".#${target}" } alias shell="nix_shell" @@ -102,13 +75,4 @@ function _comp_hosts() { _autocomplete_first ${targets[@]} } -# Autocomplete with available shells. -function _comp_shells() { - local IFS=$'\n' - local targets=($(ls ~/.config/linux/shell/ | sed -e "s/.nix$//" | tr '[:upper:]' '[:lower:]')) - - _autocomplete_first ${targets[@]} -} - -complete -F _comp_hosts nix_update nix_switch nix_rebuild -complete -F _comp_shells nix_shell shell +complete -F _comp_hosts nix_switch nix_rebuild diff --git a/.config/linux/shell/TODO b/.config/linux/shell/TODO deleted file mode 100644 index a598ce3..0000000 --- a/.config/linux/shell/TODO +++ /dev/null @@ -1 +0,0 @@ -Use flakes here with devShell