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