mirror of
https://github.com/RGBCube/ncc
synced 2025-08-01 12:37:46 +00:00
Refactor the whole codebase. Most notable changes:
- No more fail2ban. It didn't work properly anyways, I'll need to look into this in the future - No nix-super. I don't need it and the overlay is broken so I'm waiting for that to be fixed first. - Uses nh instead of nixos-rebuild. This is much better.
This commit is contained in:
parent
f145bdaa4a
commit
62c575774b
106 changed files with 1252 additions and 1367 deletions
51
rebuild.nu
51
rebuild.nu
|
@ -1,29 +1,40 @@
|
|||
#!/usr/bin/env nu
|
||||
|
||||
def complete [] {
|
||||
ls hosts | get name | each { $in | str replace "hosts/" "" }
|
||||
}
|
||||
|
||||
def main --wrapped [
|
||||
host: string@complete = "" # The host to build.
|
||||
...arguments # The arguments to pass to `nixos-rebuild switch`.
|
||||
host: string = "" # The host to build.
|
||||
...arguments # The arguments to pass to `nixos-rebuild switch`.
|
||||
] {
|
||||
let flags = [
|
||||
$"--flake ('.#' + $host)"
|
||||
"--show-trace"
|
||||
"--option accept-flake-config true"
|
||||
"--log-format internal-json"
|
||||
] | append $arguments
|
||||
|
||||
if $host == (hostname) or $host == "" {
|
||||
sudo sh -c $"nixos-rebuild switch ($flags | str join ' ') |& nom --json"
|
||||
let host = if ($host | is-not-empty) {
|
||||
$host
|
||||
} else {
|
||||
git ls-files | rsync --rsh "ssh -q" --delete --compress --files-from - ./ cube:Configuration
|
||||
(hostname)
|
||||
}
|
||||
|
||||
ssh -q $host $"sh -c '
|
||||
let args_split = $arguments | split list "--"
|
||||
|
||||
let nh_flags = [
|
||||
"--hostname" $host
|
||||
] | append ($args_split | get --ignore-errors 0 | default [])
|
||||
|
||||
let nix_flags = [
|
||||
"--option" "accept-flake-config" "true"
|
||||
] | append ($args_split | get --ignore-errors 1 | default [])
|
||||
|
||||
if $host == (hostname) {
|
||||
nh os switch . ...$nh_flags -- ...$nix_flags
|
||||
} else {
|
||||
git ls-files | (
|
||||
rsync
|
||||
--rsh "ssh -q"
|
||||
--delete --delete-excluded
|
||||
--compress
|
||||
--files-from -
|
||||
./ ($host + ":Configuration")
|
||||
)
|
||||
|
||||
ssh -q $host $"
|
||||
cd Configuration
|
||||
nix flake archive
|
||||
sudo nixos-rebuild switch ($flags | str join ' ') |& nom --json
|
||||
'"
|
||||
./rebuild.nu ($host) ($arguments | str join ' ')
|
||||
"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue