From bf121f0671cb64337f5631417b94fdb6b2b9ef3a Mon Sep 17 00:00:00 2001 From: Cody Allen Date: Fri, 24 Jan 2025 10:06:07 -0500 Subject: [PATCH] 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. --- nixos/modules/services/backup/restic.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/backup/restic.nix b/nixos/modules/services/backup/restic.nix index cde2107eb3f4..aaddc5d16589 100644 --- a/nixos/modules/services/backup/restic.nix +++ b/nixos/modules/services/backup/restic.nix @@ -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