NOflake/users/tao/nushell/extras/nix.nu

63 lines
1.6 KiB
Text
Raw Normal View History

2025-02-20 14:55:55 -08:00
alias nd = nix develop
2025-03-06 00:20:30 -08:00
2025-04-01 13:27:41 -07:00
def ns [...packages: string] {
let packages = $packages | each {$"nixpkgs#($in)"}
nix shell ...$packages
2025-02-20 14:55:55 -08:00
}
2025-03-06 00:20:30 -08:00
2025-03-14 18:07:44 -07:00
# def nr [package] {
# nix search nixpkgs $package
# }
2025-02-20 14:55:55 -08:00
2025-03-14 18:07:44 -07:00
def rebuild [subcommand, --builders: string] {
2025-03-06 17:05:34 -08:00
mut builders = $builders;
2025-02-20 14:55:55 -08:00
if (open /etc/hostname --raw) == "NOlaptop\n" and ($builders != "") {
2025-03-06 17:05:34 -08:00
if (ping -c1 -W1 nocomputer | complete | $in.exit_code == 0) {
sudo nix store info --store ssh://nocomputer
} else {
$builders = ""
}
2025-02-20 14:55:55 -08:00
}
if ($builders == "") {
2025-11-02 14:11:40 -08:00
sudo systemd-inhibit nice -n19 nixos-rebuild $subcommand --flake . --accept-flake-config --impure --verbose --builders "" o+e>| nom
2025-02-20 14:55:55 -08:00
} else {
2025-11-02 14:11:40 -08:00
sudo systemd-inhibit nice -n19 nixos-rebuild $subcommand --flake . --accept-flake-config --impure --verbose o+e>| nom
}
if $env.LAST_EXIT_CODE == 0 {
toastify send "rebuild" "done!"
return true
} else {
toastify send "rebuild" "failed!"
return false
2025-02-20 14:55:55 -08:00
}
}
2025-03-06 00:20:30 -08:00
2025-02-20 14:55:55 -08:00
def post-rebuild [] {
rm -r ~/.config/helix/runtime/grammars/
hx --grammar fetch; hx --grammar build
rustup update
}
2025-03-06 00:20:30 -08:00
2025-03-14 18:07:44 -07:00
def bump [...rest] {
2025-02-20 14:55:55 -08:00
cd /home/tao/projects/NOflake/
2025-11-02 14:11:40 -08:00
match (jj log -r @ --no-pager --no-graph --template 'if(empty, "empty", self.description())') {
"empty" => {
jj desc -m "bump (unbuilt)"
}
"bump (unbuilt)" | "bump (failed)" => {}
2025-03-27 12:06:17 -07:00
}
2025-11-02 14:11:40 -08:00
sudo nix flake update
2025-02-20 14:55:55 -08:00
# rc2nix | save -f /home/tao/projects/NOflake/users/tao/plasma.nix;
2025-11-02 14:11:40 -08:00
if (rebuild boot) {
jj desc -m $"bump (date now | format date "%Y-%m-%d")"
} else {
jj desc -m "bump (failed)"
}
2025-02-20 14:55:55 -08:00
jj new
}
2025-03-06 00:20:30 -08:00
2025-02-20 14:55:55 -08:00
alias rb = rebuild boot
alias rs = rebuild switch
alias gc = nh clean all