nixos-config/nixos/legacy/borg-scripts.nix
2024-06-03 22:01:55 +02:00

24 lines
740 B
Nix

{ pkgs, lib, ... }: {
environment.systemPackages =
let
createScript = command: target: repository:
pkgs.writers.writeBashBin
"borg-${command}-on-${target}-for-${repository}" ''
${pkgs.borgbackup}/bin/borg \
${command} \
--rsh='ssh -i ~/.ssh/palo_rsa.pub' ${target}.private:${repository}/. \
"$@"
'';
targets = [ "borg@pepe" "borg@robi" "borg@cream" "removable@cream" ];
repositories = [ "pepe" "sterni" "robi" "cream" ];
commands = [ "list" "mount" ];
in
lib.flatten (map
(command:
map
(target: map (repository: createScript command target repository) repositories)
targets)
commands);
}