Files
nixos/home/baseline/nushell/functions.nu
T
Greg Hellings 673f9b1f8b
buildbot/nix-eval Build done.
buildbot/nix-build gitea:greg/nixos#checks.x86_64-linux.pkg-setup-ssh Build done.
buildbot/nix-build gitea:greg/nixos#checks.x86_64-linux.hm-jeremiah Build done.
buildbot/nix-build gitea:greg/nixos#checks.x86_64-linux.hm-icdm-root Build done.
buildbot/nix-build gitea:greg/nixos#checks.x86_64-linux.hm-linode Build done.
buildbot/nix-build gitea:greg/nixos#checks.x86_64-linux.hm-exodus Build done.
buildbot/nix-build gitea:greg/nixos#checks.x86_64-linux.hm-zeke Build done.
buildbot/nix-build Build done.
chore: expose credentials to Claude
2026-04-22 21:59:30 -05:00

83 lines
2.5 KiB
Nu

# vim: set filetype=nushell :
let servers = [isaiah jeremiah zeke genesis vm-gitlab]
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
}
}
def rebuild [] {
if (uname | get operating-system) == "Darwin" {
sudo darwin-rebuild switch
} else {
let hostname = uname | get nodename
let build = ^nom build --keep-going $"/etc/nixos#nixosConfigurations.($hostname).config.system.build.toplevel"
if $env.LAST_EXIT_CODE == 0 {
nvd diff /run/current-system result
run0 result/bin/switch-to-configuration switch
} else {
print "Error during build"
}
}
}
def deploy [ $host: string, $build: string = "" ] {
mut buildhost = $build
if $build == "" {
$buildhost = $host
}
if $buildhost == "linode" or $buildhost == "genesis" {
$buildhost = "isaiah"
}
nixos-rebuild switch --sudo --use-substitutes --target-host $host --build-host $buildhost
}
def ff [ $file: string ] {
ls **/* | where name =~ $file
}
def update_all [] {
par-map $servers {|e| deploy $e | complete} | explore
}
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 .
}
def podman_image_clean [] {
podman rmi ...(^podman images --format=json | from json | where {|e| not ("Names" in $e)} | get Id)
}
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),
}
}
def claude [ ] {
unlock
$env.GITLAB_TOKEN = ^bw get item 7d3da4e9-5f9a-49d0-8e14-b39c010a4001 | from json | get fields | find claudeapi | get value
$env.ANTHROPIC_API_KEY = ^bw get item e122fd08-3506-4f21-9c6a-b42b00fe5be1 | from json | get login.password
^claude
}
if ("/usr/local/bin" | path exists) {
$env.PATH = $env.PATH | append "/usr/local/bin"
}
$env.PATH = $env.PATH | prepend "~/.local/bin"