Files
nixos-config/apps/aarch64-darwin/build-switch
2026-03-05 15:41:41 +00:00

31 lines
861 B
Plaintext
Executable File

#!/usr/bin/env nu
use ../common.nu *
def main [hostname?: string, ...rest: string] {
let host = if ($hostname | is-empty) {
try { scutil --get LocalHostName | str trim } catch { hostname -s | str trim }
} else { $hostname }
print_info $"Building and switching configuration for ($host)"
# Build
print_info "Building configuration..."
if (nix build $".#darwinConfigurations.($host).system" --show-trace ...$rest | complete).exit_code != 0 {
print_error "Build failed"
exit 1
}
print_success "Build completed"
# Switch
print_info "Switching to new configuration..."
sudo ./result/sw/bin/darwin-rebuild switch --flake $".#($host)" ...$rest
if ("./result" | path exists) {
rm ./result
}
print_success "Build and switch completed successfully"
}