Unify apply script across platforms and remove build-switch
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
#!/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"
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
#!/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 $"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"
|
||||
}
|
||||
Reference in New Issue
Block a user