Nix : Shell to spawn nix-shell.

This commit is contained in:
Dmitry Voronin 2024-01-28 21:21:35 +03:00
parent 197f7bcb0a
commit 0ced40b4f0
2 changed files with 16 additions and 3 deletions

View file

@ -71,7 +71,20 @@ function nix_shell() {
nix_shell="${name}" nix-shell ~/.config/linux/shell/"${name^}".nix
}
alias shell="nix_shell"
alias mkshell="nix_shell"
# Spawn nix-shell with specified packages.
# Usage: shell <PACKAGES>
function shell() {
local pkgs="${*}"
if [[ "${pkgs}" = "" ]]; then
help shell
return 2
fi
nix-shell -p "${pkgs}"
}
# Autocomplete with available hosts.
function _comp_hosts() {
@ -87,8 +100,7 @@ function _comp_shells() {
local targets=($(ls ~/.config/linux/shell/ | sed -e "s/.nix$//" | tr '[:upper:]' '[:lower:]'))
_autocomplete_first ${targets[@]}
}
complete -F _comp_hosts nix_update nix_upgrade
complete -F _comp_shells nix_shell shell
complete -F _comp_shells nix_shell mkshell

View file

@ -280,6 +280,7 @@ Command|Description
`nix_upgrade [HOSTNAME]`|Upgrade system. Applies after reboot. Optionally force the hostname.
`nix_clean`|Free up root space.
`nix_shell [NAME]`|Spawn shell with specified nix environment. `Main` is default.
`shell <PACKAGES>`|Spawn nix-shell with specified packages.
## Notify.