2025-10-01 19:51:55 -05:00
|
|
|
{
|
|
|
|
|
flake,
|
|
|
|
|
config,
|
|
|
|
|
lib,
|
|
|
|
|
...
|
|
|
|
|
}:
|
|
|
|
|
let
|
|
|
|
|
inherit (flake.config.machines) devices;
|
|
|
|
|
inherit (flake.config.services) instances;
|
|
|
|
|
hostname = config.networking.hostName;
|
2025-11-13 19:54:25 -06:00
|
|
|
dotPath = "~/projects/dotfiles";
|
2025-11-19 17:00:17 -06:00
|
|
|
mkLocalRebuild = ''
|
|
|
|
|
rebuild:
|
|
|
|
|
nixos-rebuild switch --sudo --flake ${dotPath}#${hostname} --show-trace
|
2025-11-13 19:54:25 -06:00
|
|
|
'';
|
|
|
|
|
mkRemoteRebuild = name: ip: ''
|
2025-11-19 17:00:17 -06:00
|
|
|
rebuild-${name}:
|
2025-11-13 19:54:25 -06:00
|
|
|
nixos-rebuild switch --flake ${dotPath}#${name} --target-host ${ip} --sudo --ask-sudo-password --show-trace
|
|
|
|
|
'';
|
|
|
|
|
mkSshCommands = name: ip: ''
|
2025-11-19 17:00:17 -06:00
|
|
|
${name}:
|
2025-11-13 19:54:25 -06:00
|
|
|
ssh ${ip}
|
|
|
|
|
'';
|
|
|
|
|
mkMicrVMSshCommands = name: ssh: ''
|
|
|
|
|
${name}:
|
2025-11-13 19:56:52 -06:00
|
|
|
ssh -p ${builtins.toString ssh} root@localhost
|
2025-11-13 19:54:25 -06:00
|
|
|
'';
|
2025-11-21 02:58:02 -06:00
|
|
|
balanceHosts = lib.concatStringsSep ", " [
|
2025-11-21 03:17:14 -06:00
|
|
|
''{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}"}''
|
2025-11-21 02:58:02 -06:00
|
|
|
];
|
2025-11-13 19:54:25 -06:00
|
|
|
systemRecords =
|
|
|
|
|
command:
|
|
|
|
|
lib.concatStrings [
|
|
|
|
|
(command devices.ceres.name devices.ceres.ip.address0)
|
|
|
|
|
(command devices.eris.name devices.eris.ip.address0)
|
2025-11-13 19:56:52 -06:00
|
|
|
(command devices.mars.name devices.mars.ip.address0)
|
2025-11-13 19:54:25 -06:00
|
|
|
(command devices.deimos.name devices.deimos.ip.address0)
|
|
|
|
|
(command devices.phobos.name devices.phobos.ip.address0)
|
2025-11-21 02:58:02 -06:00
|
|
|
(command "lamba" "-o StrictHostKeyChecking=no denise@192.168.50.131")
|
2025-11-13 19:54:25 -06:00
|
|
|
];
|
|
|
|
|
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)
|
2025-11-13 20:09:28 -06:00
|
|
|
(command instances.firefly-iii.name instances.firefly-iii.interface.ssh)
|
2025-11-13 19:54:25 -06:00
|
|
|
(command instances.mastodon.name instances.mastodon.interface.ssh)
|
|
|
|
|
];
|
2025-11-19 17:00:17 -06:00
|
|
|
localRebuild = mkLocalRebuild;
|
2025-11-13 19:54:25 -06:00
|
|
|
remoteRebuild = systemRecords mkRemoteRebuild;
|
|
|
|
|
sshCommand = systemRecords mkSshCommands;
|
|
|
|
|
microVMSshCommand = instanceRecords mkMicrVMSshCommands;
|
2025-10-01 19:51:55 -05:00
|
|
|
in
|
|
|
|
|
{
|
2025-11-13 19:54:25 -06:00
|
|
|
text = ''
|
|
|
|
|
${localRebuild}
|
|
|
|
|
${remoteRebuild}
|
|
|
|
|
${sshCommand}
|
|
|
|
|
${microVMSshCommand}
|
2025-11-21 02:58:02 -06:00
|
|
|
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
|
2025-11-13 19:54:25 -06:00
|
|
|
'';
|
2025-10-01 19:51:55 -05:00
|
|
|
}
|