laptop-nix-config/switch.nu
2025-03-31 23:26:52 -06:00

28 lines
564 B
Plaintext
Executable file

#!/usr/bin/env nu
def --wrapped rebuild [subcmd: string, ...rest] {
nix fmt
git add -A # make sure the goddamn files are added because nix stores won't include unchecked files
let r = echo ...$rest | into string;
nix-shell -p nixos-rebuild --command $"sudo nixos-rebuild --flake . ($subcmd) ($r)";
};
def --wrapped "main switch" [
...rest
] {
rebuild switch ...$rest
}
def --wrapped "main boot" [
--restart (-r) # restart after building
...rest
] {
rebuild boot ...$rest
if $restart {
sudo reboot now
}
}
def main [] {
main switch
}