Nix : Allow specifying hostname for update.

This commit is contained in:
Dmitry Voronin 2024-01-26 03:06:39 +03:00
parent d0ba35a059
commit 36311e8315

View file

@ -38,13 +38,23 @@ function nix_channel() {
}
# Update system (rebuild).
# Optionally force the hostname.
# Usage: nix_update [HOSTNAME]
function nix_update() {
nixos-rebuild switch -I nixos-config=/root/.config/linux/system/${HOSTNAME}/Configuration.nix
local target="${1}"
[[ "${target}" = "" ]] && target="${HOSTNAME}"
nixos-rebuild switch -I nixos-config=/root/.config/linux/system/${target}/Configuration.nix
}
# Upgrade system.
# Optionally force the hostname.
# Usage: nix_upgrade [HOSTNAME]
function nix_upgrade() {
nixos-rebuild switch --upgrade -I nixos-config=/root/.config/linux/system/${HOSTNAME}/Configuration.nix
local target="${1}"
[[ "${target}" = "" ]] && target="${HOSTNAME}"
nixos-rebuild switch --upgrade -I nixos-config=/root/.config/linux/system/${target}/Configuration.nix
}
# Free up root space.
@ -62,3 +72,13 @@ function nix_shell() {
function shell() {
nix-shell -p "${@}"
}
# Autocomplete with available hosts.
function _comp_hosts() {
local IFS=$'\n'
local targets=($(ls --classify ~/.config/linux/system/ | grep /$ | sed -e "s/\/$//"))
_autocomplete_first ${targets[@]}
}
complete -F _comp_hosts nix_update nix_upgrade