xin/bins/restic.nix

21 lines
456 B
Nix
Raw Permalink Normal View History

2023-07-11 09:12:50 -06:00
{
lib,
pkgs,
config,
...
}:
assert (builtins.length
2023-07-11 09:12:50 -06:00
(lib.mapAttrsToList (a: _: a) config.services.restic.backups))
<= 1; let
resticBin = "${pkgs.restic}/bin/restic";
cfg = config.services.restic.backups;
bkp = lib.mapAttrs' (_: lib.nameValuePair "default") cfg;
in ''
#!/usr/bin/env sh
set -e
export $(cat ${bkp.default.environmentFile})
${resticBin} -r ${bkp.default.repository} --password-file ${bkp.default.passwordFile} $@
''