2025-09-21 18:53:42 -05:00
|
|
|
# vim: set filetype=nushell :
|
2026-04-30 16:06:58 -05:00
|
|
|
let servers = [isaiah jeremiah zeke genesis]
|
2025-09-11 21:39:34 -05:00
|
|
|
|
2025-09-11 12:15:39 -05:00
|
|
|
def par-map [ items: list, c: closure ] {
|
|
|
|
|
let results = $items | par-each -k $c
|
|
|
|
|
$items | enumerate | reduce -f {} {|e, a| $a | upsert $e.item { $results | get $e.index }}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def --env unlock [] {
|
|
|
|
|
if "BW_SESSION" not-in $env {
|
|
|
|
|
$env.BW_SESSION = ^bw unlock --raw
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-24 12:49:32 -05:00
|
|
|
def rebuild [ $target: string = "switch" ] {
|
2025-09-11 12:15:39 -05:00
|
|
|
if (uname | get operating-system) == "Darwin" {
|
2026-06-24 12:49:32 -05:00
|
|
|
sudo darwin-rebuild $target
|
2025-09-11 12:15:39 -05:00
|
|
|
} else {
|
|
|
|
|
let hostname = uname | get nodename
|
2025-09-30 21:57:11 -05:00
|
|
|
let build = ^nom build --keep-going $"/etc/nixos#nixosConfigurations.($hostname).config.system.build.toplevel"
|
2025-09-21 18:53:42 -05:00
|
|
|
if $env.LAST_EXIT_CODE == 0 {
|
|
|
|
|
nvd diff /run/current-system result
|
2026-06-24 12:49:32 -05:00
|
|
|
run0 result/bin/switch-to-configuration $target
|
2025-09-21 18:53:42 -05:00
|
|
|
} else {
|
|
|
|
|
print "Error during build"
|
|
|
|
|
}
|
2025-09-11 12:15:39 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def deploy [ $host: string, $build: string = "" ] {
|
|
|
|
|
mut buildhost = $build
|
|
|
|
|
if $build == "" {
|
|
|
|
|
$buildhost = $host
|
|
|
|
|
}
|
2025-09-27 09:19:17 -05:00
|
|
|
if $buildhost == "linode" or $buildhost == "genesis" {
|
2025-09-11 12:15:39 -05:00
|
|
|
$buildhost = "isaiah"
|
|
|
|
|
}
|
2025-09-11 23:01:00 -05:00
|
|
|
nixos-rebuild switch --sudo --use-substitutes --target-host $host --build-host $buildhost
|
2025-09-11 12:15:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def ff [ $file: string ] {
|
|
|
|
|
ls **/* | where name =~ $file
|
|
|
|
|
}
|
2025-09-11 21:39:34 -05:00
|
|
|
|
|
|
|
|
def update_all [] {
|
2025-09-11 23:01:00 -05:00
|
|
|
par-map $servers {|e| deploy $e | complete} | explore
|
2025-09-11 21:39:34 -05:00
|
|
|
}
|
2025-09-12 13:25:00 -05:00
|
|
|
|
|
|
|
|
def bake [template: string] {
|
|
|
|
|
let copier = "~/.copier-templates" | path expand
|
|
|
|
|
if not ($copier | path exists) {
|
|
|
|
|
git clone srcpub:greg/copier-templates.git $copier
|
|
|
|
|
}
|
|
|
|
|
let srcdir = [$copier $template] | path join
|
|
|
|
|
print $srcdir
|
|
|
|
|
copier copy $srcdir .
|
|
|
|
|
}
|
2025-10-09 16:22:57 -05:00
|
|
|
|
|
|
|
|
def podman_image_clean [] {
|
|
|
|
|
podman rmi ...(^podman images --format=json | from json | where {|e| not ("Names" in $e)} | get Id)
|
|
|
|
|
}
|
2025-10-14 09:53:27 -05:00
|
|
|
|
|
|
|
|
def dc [ $cmd: string = "sh" ] {
|
|
|
|
|
match $cmd {
|
|
|
|
|
"up" => (devcontainer up --workspace-folder . --docker-path podman),
|
|
|
|
|
"sh" => (devcontainer exec --workspace-folder . --docker-path podman bash),
|
|
|
|
|
"down" => (podman compose -f .devcontainer/(open .devcontainer/devcontainer.json | get dockerComposeFile | first) down),
|
|
|
|
|
_ => (devcontainer --help),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-13 16:00:26 -05:00
|
|
|
def claude [ ] {
|
|
|
|
|
unlock
|
2026-04-22 21:59:30 -05:00
|
|
|
$env.GITLAB_TOKEN = ^bw get item 7d3da4e9-5f9a-49d0-8e14-b39c010a4001 | from json | get fields | find claudeapi | get value
|
2026-04-30 14:42:29 -05:00
|
|
|
#$env.ANTHROPIC_API_KEY = ^bw get item e122fd08-3506-4f21-9c6a-b42b00fe5be1 | from json | get login.password
|
2026-04-13 16:00:26 -05:00
|
|
|
^claude
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-14 09:53:27 -05:00
|
|
|
if ("/usr/local/bin" | path exists) {
|
|
|
|
|
$env.PATH = $env.PATH | append "/usr/local/bin"
|
|
|
|
|
}
|
2026-04-06 16:50:06 -05:00
|
|
|
$env.PATH = $env.PATH | prepend "~/.local/bin"
|