dotfiles/profiles/user0/files/misc/justfile.nix
2025-12-10 18:09:00 -06:00

43 lines
1.1 KiB
Nix
Executable file

{
flake,
config,
lib,
...
}:
let
inherit (flake.config.machines) devices;
hostname = config.networking.hostName;
dotPath = "~/projects/dotfiles";
mkLocalRebuild = ''
rebuild:
nixos-rebuild switch --sudo --flake ${dotPath}#${hostname} --show-trace
'';
mkRemoteRebuild = name: ip: ''
rebuild-${name}:
nixos-rebuild switch --flake ${dotPath}#${name} --target-host ${ip} --sudo --ask-sudo-password --show-trace
'';
mkSshCommands = name: ip: ''
${name}:
ssh ${ip}
'';
systemRecords =
command:
lib.concatStrings [
(command devices.ceres.name devices.ceres.ip.address0)
(command devices.eris.name devices.eris.ip.address0)
(command devices.mars.name devices.mars.ip.address0)
(command devices.deimos.name devices.deimos.ip.address0)
(command devices.phobos.name devices.phobos.ip.address0)
(command "lamba" "-o StrictHostKeyChecking=no denise@192.168.50.131")
];
localRebuild = mkLocalRebuild;
remoteRebuild = systemRecords mkRemoteRebuild;
sshCommand = systemRecords mkSshCommands;
in
{
text = ''
${localRebuild}
${remoteRebuild}
${sshCommand}
'';
}