dendritic migration
dendritic migration
This commit is contained in:
@@ -1,16 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env nu
|
||||
|
||||
set -euo pipefail
|
||||
source "$(dirname "$0")/../common.sh"
|
||||
use ../common.nu *
|
||||
|
||||
HOSTNAME="${1:-$(hostname)}"
|
||||
|
||||
print_info "Applying configuration for $HOSTNAME"
|
||||
|
||||
if [[ "$EUID" -ne 0 ]]; then
|
||||
sudo nixos-rebuild switch --flake ".#$HOSTNAME" "${@:2}"
|
||||
else
|
||||
nixos-rebuild switch --flake ".#$HOSTNAME" "${@:2}"
|
||||
fi
|
||||
|
||||
print_success "Configuration applied successfully"
|
||||
def main [hostname?: string, ...rest: string] {
|
||||
let host = if ($hostname | is-empty) {
|
||||
hostname | str trim
|
||||
} else { $hostname }
|
||||
|
||||
print_info $"Applying configuration for ($host)"
|
||||
|
||||
let euid = (id -u | str trim | into int)
|
||||
|
||||
if $euid != 0 {
|
||||
sudo nixos-rebuild switch --flake $".#($host)" ...$rest
|
||||
} else {
|
||||
nixos-rebuild switch --flake $".#($host)" ...$rest
|
||||
}
|
||||
|
||||
print_success "Configuration applied successfully"
|
||||
}
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env nu
|
||||
|
||||
set -euo pipefail
|
||||
source "$(dirname "$0")/../common.sh"
|
||||
use ../common.nu *
|
||||
|
||||
HOSTNAME="${1:-$(hostname)}"
|
||||
|
||||
print_info "Building configuration for $HOSTNAME"
|
||||
|
||||
nix build ".#nixosConfigurations.$HOSTNAME.config.system.build.toplevel" --show-trace "${@:2}"
|
||||
|
||||
if [[ -L ./result ]]; then
|
||||
unlink ./result
|
||||
fi
|
||||
|
||||
print_success "Build completed successfully"
|
||||
def main [hostname?: string, ...rest: string] {
|
||||
let host = if ($hostname | is-empty) {
|
||||
hostname | str trim
|
||||
} else { $hostname }
|
||||
|
||||
print_info $"Building configuration for ($host)"
|
||||
|
||||
nix build $".#nixosConfigurations.($host).config.system.build.toplevel" --show-trace ...$rest
|
||||
|
||||
if ("./result" | path exists) {
|
||||
rm ./result
|
||||
}
|
||||
|
||||
print_success "Build completed successfully"
|
||||
}
|
||||
|
||||
@@ -1,26 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env nu
|
||||
|
||||
set -euo pipefail
|
||||
source "$(dirname "$0")/../common.sh"
|
||||
use ../common.nu *
|
||||
|
||||
HOSTNAME="${1:-$(hostname)}"
|
||||
|
||||
print_info "Building and switching configuration for $HOSTNAME"
|
||||
|
||||
# Build
|
||||
print_info "Building configuration..."
|
||||
if ! nix build ".#nixosConfigurations.$HOSTNAME.config.system.build.toplevel" --no-link "${@:2}"; then
|
||||
print_error "Build failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_success "Build completed"
|
||||
|
||||
print_info "Switching to new configuration..."
|
||||
if [[ "$EUID" -ne 0 ]]; then
|
||||
sudo nixos-rebuild switch --flake ".#$HOSTNAME" "${@:2}"
|
||||
else
|
||||
nixos-rebuild switch --flake ".#$HOSTNAME" "${@:2}"
|
||||
fi
|
||||
|
||||
print_success "Build and switch completed successfully"
|
||||
def main [hostname?: string, ...rest: string] {
|
||||
let host = if ($hostname | is-empty) {
|
||||
hostname | str trim
|
||||
} else { $hostname }
|
||||
|
||||
print_info $"Building and switching configuration for ($host)"
|
||||
|
||||
# Build
|
||||
print_info "Building configuration..."
|
||||
if (nix build $".#nixosConfigurations.($host).config.system.build.toplevel" --no-link ...$rest | complete).exit_code != 0 {
|
||||
print_error "Build failed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
print_success "Build completed"
|
||||
|
||||
# Switch
|
||||
print_info "Switching to new configuration..."
|
||||
let euid = (id -u | str trim | into int)
|
||||
|
||||
if $euid != 0 {
|
||||
sudo nixos-rebuild switch --flake $".#($host)" ...$rest
|
||||
} else {
|
||||
nixos-rebuild switch --flake $".#($host)" ...$rest
|
||||
}
|
||||
|
||||
print_success "Build and switch completed successfully"
|
||||
}
|
||||
|
||||
60
apps/x86_64-linux/rollback
Normal file → Executable file
60
apps/x86_64-linux/rollback
Normal file → Executable file
@@ -1,30 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env nu
|
||||
|
||||
set -euo pipefail
|
||||
source "$(dirname "$0")/../common.sh"
|
||||
use ../common.nu *
|
||||
|
||||
print_info "Available generations:"
|
||||
if [[ "$EUID" -ne 0 ]]; then
|
||||
sudo nix-env --profile /nix/var/nix/profiles/system --list-generations
|
||||
else
|
||||
nix-env --profile /nix/var/nix/profiles/system --list-generations
|
||||
fi
|
||||
|
||||
echo -n "Enter generation number to rollback to: "
|
||||
read -r GEN_NUM
|
||||
|
||||
if [[ -z "$GEN_NUM" ]]; then
|
||||
print_error "No generation number provided"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_warning "Rolling back to generation $GEN_NUM..."
|
||||
if [[ "$EUID" -ne 0 ]]; then
|
||||
sudo nix-env --profile /nix/var/nix/profiles/system --switch-generation "$GEN_NUM" && \
|
||||
sudo /nix/var/nix/profiles/system/bin/switch-to-configuration switch
|
||||
else
|
||||
nix-env --profile /nix/var/nix/profiles/system --switch-generation "$GEN_NUM" && \
|
||||
/nix/var/nix/profiles/system/bin/switch-to-configuration switch
|
||||
fi
|
||||
|
||||
print_success "Rollback to generation $GEN_NUM complete"
|
||||
def main [] {
|
||||
print_info "Available generations:"
|
||||
|
||||
let euid = (id -u | str trim | into int)
|
||||
|
||||
if $euid != 0 {
|
||||
sudo nix-env --profile /nix/var/nix/profiles/system --list-generations
|
||||
} else {
|
||||
nix-env --profile /nix/var/nix/profiles/system --list-generations
|
||||
}
|
||||
|
||||
let gen_num = input "Enter generation number to rollback to: "
|
||||
|
||||
if ($gen_num | is-empty) {
|
||||
print_error "No generation number provided"
|
||||
exit 1
|
||||
}
|
||||
|
||||
print_warning $"Rolling back to generation ($gen_num)..."
|
||||
|
||||
if $euid != 0 {
|
||||
sudo nix-env --profile /nix/var/nix/profiles/system --switch-generation $gen_num
|
||||
sudo /nix/var/nix/profiles/system/bin/switch-to-configuration switch
|
||||
} else {
|
||||
nix-env --profile /nix/var/nix/profiles/system --switch-generation $gen_num
|
||||
/nix/var/nix/profiles/system/bin/switch-to-configuration switch
|
||||
}
|
||||
|
||||
print_success $"Rollback to generation ($gen_num) complete"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user