35 lines
1.0 KiB
Plaintext
Executable File
35 lines
1.0 KiB
Plaintext
Executable File
#!/usr/bin/env nu
|
|
|
|
use ../common.nu *
|
|
|
|
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"
|
|
}
|