mirror of
https://github.com/RGBCube/ncc
synced 2025-08-02 04:57:45 +00:00
Rewrite rebuild script in Nu
This commit is contained in:
parent
95d330492f
commit
0f0e233ba4
4 changed files with 115 additions and 18 deletions
30
rebuild.nu
Executable file
30
rebuild.nu
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env nu
|
||||
|
||||
def main [
|
||||
machine: string = "" # The machine to build.
|
||||
...arguments # Extra arguments to pass to nixos-rebuild.
|
||||
] {
|
||||
mut machine_ = $machine
|
||||
|
||||
let valid_machines = ls machines | where type == dir | get name | each { $in | str replace "machines/" "" }
|
||||
|
||||
if ($machine_ | is-empty) {
|
||||
$machine_ = (input $"Select machine to build [($valid_machines | str join ', ')]: ")
|
||||
|
||||
if ($machine_ | is-empty) and ($valid_machines | length) == 1 {
|
||||
$machine_ = ($valid_machines | get 0)
|
||||
} else {
|
||||
main "" ($arguments | str join " ")
|
||||
exit
|
||||
}
|
||||
}
|
||||
|
||||
if not ($machine_ in $valid_machines) {
|
||||
main "" ($arguments | str join " ")
|
||||
exit
|
||||
}
|
||||
|
||||
nix-shell --packages git --command $"sudo nixos-rebuild switch --impure --flake .#($machine) ($arguments | str join ' ')"
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue