feat: updated abstractions

This commit is contained in:
Nick 2025-12-10 18:09:00 -06:00
parent 4512d7a5d9
commit 9aab8c6444
31 changed files with 70 additions and 97 deletions

View file

@ -6,7 +6,6 @@
}:
let
inherit (flake.config.machines) devices;
inherit (flake.config.services) instances;
hostname = config.networking.hostName;
dotPath = "~/projects/dotfiles";
mkLocalRebuild = ''
@ -21,18 +20,6 @@ let
${name}:
ssh ${ip}
'';
mkMicrVMSshCommands = name: ssh: ''
${name}:
ssh -p ${builtins.toString ssh} root@localhost
'';
balanceHosts = lib.concatStringsSep ", " [
''{name: "${devices.ceres.name}", ssh: "${devices.ceres.ip.address0}"}''
''{name: "${devices.eris.name}", ssh: "${devices.eris.ip.address0}"}''
''{name: "${devices.mars.name}", ssh: "${devices.mars.ip.address0}"}''
''{name: "${devices.deimos.name}", ssh: "${devices.deimos.ip.address0}"}''
''{name: "${devices.phobos.name}", ssh: "${devices.phobos.ip.address0}"}''
''{name: "${devices.lamdagibson.short}", ssh: "-o StrictHostKeyChecking=no denise@${devices.lamdagibson.ip.address0}"}''
];
systemRecords =
command:
lib.concatStrings [
@ -43,31 +30,14 @@ let
(command devices.phobos.name devices.phobos.ip.address0)
(command "lamba" "-o StrictHostKeyChecking=no denise@192.168.50.131")
];
instanceRecords =
command:
lib.concatStrings [
(command instances.vaultwarden.name instances.vaultwarden.interface.ssh)
(command instances.jellyfin.name instances.jellyfin.interface.ssh)
(command instances.forgejo.name instances.forgejo.interface.ssh)
(command instances.firefly-iii.name instances.firefly-iii.interface.ssh)
(command instances.mastodon.name instances.mastodon.interface.ssh)
];
localRebuild = mkLocalRebuild;
remoteRebuild = systemRecords mkRemoteRebuild;
sshCommand = systemRecords mkSshCommands;
microVMSshCommand = instanceRecords mkMicrVMSshCommands;
in
{
text = ''
${localRebuild}
${remoteRebuild}
${sshCommand}
${microVMSshCommand}
balance:
#!/usr/bin/env nu
let results = [${balanceHosts}] | each { |h| let val = (^ssh ...($h.ssh | split row " ") 'nu -c "open /var/lib/defenseio-data/MidnightMiner/balances.json | get snapshots | last | get balance"' | into float); print $"($h.name):"; print $val; $val }
print "---"
print "total:"
$results | math sum
'';
}