Skip to content

Commit

Permalink
~ rewrite auxiliary script
Browse files Browse the repository at this point in the history
  • Loading branch information
oluceps committed Nov 7, 2023
1 parent 6767b38 commit 4ca47c7
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions setup.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env -S nu --stdin

def copy_secrets [a: string, h: string] {
(nix copy --substitute-on-destination --to $'ssh://($a)'
(nix eval --raw $'.#nixosConfigurations.($h).config.age.rekey.derivation') -vvv)
}

def prepare_configuration [x: string] {
nix build $".#nixosConfigurations.($x).config.system.build.toplevel --log-format internal-json -v 2>&1 | nom --json"
}

def main [x: string, y: string = "", z: string = ""] {
const general_set = ["hastur" "azasos" "kaambl" "yidhra" "nodens"]

if $x == 'cp' {
if $z == 'all' {
$general_set | each { |i| copy_secrets $y $i }
return
}
(ssh $y hostname) | copy_secrets $y $in
print completed.
}

if $x == 'pre' {
if $y == 'all' {
$general_set | each { |i| prepare_configuration $i }
}
}

if $x == 'help' {
print 'cp <ssh alias>' 'cp <ssh alias> all' 'pre <hostname>'
}
}

0 comments on commit 4ca47c7

Please sign in to comment.