Nix : Make nix_shell multi-module.

This commit is contained in:
Dmitry Voronin 2024-01-28 20:57:01 +03:00
parent f56cf5c84c
commit ad0cbb12f3
4 changed files with 29 additions and 8 deletions

View file

@ -63,14 +63,13 @@ function nix_clean() {
[[ "${UID}" = 0 ]] && nix-store --gc
}
# Spawn shell with nix environment, like LD support.
# Spawn shell with specified nix environment. `Main` is default.
# Usage: nix_shell [NAME]
function nix_shell() {
nix-shell ~/.config/linux/Shell.nix
}
local name="${1,,}"
[[ "${name}" = "" ]] && name="main"
# Spawn temporary shell.
function shell() {
nix-shell -p "${@}"
nix_shell="${name}" nix-shell ~/.config/linux/shell/"${name^}".nix
}
# Autocomplete with available hosts.
@ -81,4 +80,14 @@ 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_upgrade
complete -F _comp_shells nix_shell

View file

@ -72,6 +72,11 @@ function __prompt_command() {
PS1+="\n"
PS1+="\[${color_default}\]"
# Show nix shell name.
if [ -n "${nix_shell}" ]; then
PS1+="${color_white}${nix_shell}${color_default} "
fi
# Show remote connections.
if [ -n "${SSH_TTY}" ]; then
PS1+=">"

View file

@ -46,6 +46,7 @@ Command|Description
`bootstrap_ffmpeg`|Install ffmpeg.
`bootstrap_editorconfig`|Install Editorconfig file (with tabs) in current directory.
`bootstrap_editorconfig_space [AMOUNT]`|Install Editorconfig file (with specified spaces, 8 by default) in current directory.
`bootstrap_flatpak`|Setup all the flatpak apps on the machine.
## Cd.
@ -113,6 +114,13 @@ Command|Description
`dconf_load`|Load Gnome settings.
`dconf_save [FILE]`|Dump Gnome settings into the file. Default name is `gnome.dconf`. Do this before changing settings and after, an then run `diff` to find out what to add to the main `gnome.dconf`.
## Disk.
Command|Description
---|---
`df`|Show only physical drives info.
`du [DIRS]`|Show combined size in SI. Current dir by default.
## Docker.
Command|Description
@ -271,8 +279,7 @@ Command|Description
`nix_update [HOSTNAME]`|Update system (rebuild). Optionally force the hostname.
`nix_upgrade [HOSTNAME]`|Upgrade system. Applies after reboot. Optionally force the hostname.
`nix_clean`|Free up root space.
`nix_shell`|Spawn shell with nix environment, like LD support.
`shell`|Spawn temporary shell.
`nix_shell [NAME]`|Spawn shell with specified nix environment. `Main` is default.
## Notify.