Unverified Commit bf121f06 authored by Cody Allen's avatar Cody Allen
Browse files

services.restic: use getExe instead of hard-coded path

Instead of assuming the restic executable is at `bin/restic`, use
`lib.getExe` on the restic package. The main motivation for this is
using a security wrapper that has a different name such as
`bin/restic-wrapper`.

NOTE: In rare cases this could be a breaking change. For example if you
are using a wrapper whose executable is at `bin/restic`,
`meta.mainProgram` is not set, _and_ your package name is something
other than `restic`.

See the [discource discussion](https://discourse.nixos.org/t/using-restic-service-with-the-security-wrapper/34547/5) for more details/discussion.
parent 9774f0ef
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -345,7 +345,7 @@ in
          "--what='sleep'"
          "--why=${lib.escapeShellArg "Scheduled backup ${name}"} "
        ];
        resticCmd = "${lib.optionalString backup.inhibitsSleep inhibitCmd}${backup.package}/bin/restic${extraOptions}";
        resticCmd = "${lib.optionalString backup.inhibitsSleep inhibitCmd}${lib.getExe backup.package}${extraOptions}";
        excludeFlags = lib.optional (
          backup.exclude != [ ]
        ) "--exclude-file=${pkgs.writeText "exclude-patterns" (lib.concatStringsSep "\n" backup.exclude)}";
@@ -455,7 +455,7 @@ in
      name: backup:
      let
        extraOptions = lib.concatMapStrings (arg: " -o ${arg}") backup.extraOptions;
        resticCmd = "${backup.package}/bin/restic${extraOptions}";
        resticCmd = "${lib.getExe backup.package}${extraOptions}";
      in
      pkgs.writeShellScriptBin "restic-${name}" ''
        set -a  # automatically export variables