nixos-config/nixos/system/all/borg-scripts.nix

25 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);
}