Nix : Allow specifying hostname for update.
This commit is contained in:
parent
d0ba35a059
commit
36311e8315
|
@ -38,13 +38,23 @@ function nix_channel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update system (rebuild).
|
# Update system (rebuild).
|
||||||
|
# Optionally force the hostname.
|
||||||
|
# Usage: nix_update [HOSTNAME]
|
||||||
function nix_update() {
|
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.
|
# Upgrade system.
|
||||||
|
# Optionally force the hostname.
|
||||||
|
# Usage: nix_upgrade [HOSTNAME]
|
||||||
function nix_upgrade() {
|
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.
|
# Free up root space.
|
||||||
|
@ -62,3 +72,13 @@ function nix_shell() {
|
||||||
function shell() {
|
function shell() {
|
||||||
nix-shell -p "${@}"
|
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
|
||||||
|
|
Reference in a new issue