xin/bins/restic.nix

21 lines
453 B
Nix
Raw Normal View History

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