From 2eabb26d0859c7710a2aa76c3b0ff4149f41b04a Mon Sep 17 00:00:00 2001 From: Jess <43591752+ttrssreal@users.noreply.github.com> Date: Sat, 3 May 2025 01:23:57 +1200 Subject: [PATCH] restic: allow the convenience script to source environmentFile (#6947) --- modules/services/restic.nix | 8 ++++++-- tests/integration/standalone/restic-home.nix | 10 ++++++++++ tests/integration/standalone/restic.nix | 8 ++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/modules/services/restic.nix b/modules/services/restic.nix index 1a5a5d7ae..59f09ae92 100644 --- a/modules/services/restic.nix +++ b/modules/services/restic.nix @@ -508,8 +508,12 @@ in in pkgs.writeShellApplication { name = "restic-${name}"; - # https://github.com/koalaman/shellcheck/issues/1986 - excludeShellChecks = [ "SC2034" ]; + excludeShellChecks = [ + # https://github.com/koalaman/shellcheck/issues/1986 + "SC2034" + # Allow sourcing environmentFile + "SC1091" + ]; bashOptions = [ "errexit" "nounset" diff --git a/tests/integration/standalone/restic-home.nix b/tests/integration/standalone/restic-home.nix index f2af5a0ae..6a981d3cd 100644 --- a/tests/integration/standalone/restic-home.nix +++ b/tests/integration/standalone/restic-home.nix @@ -119,6 +119,16 @@ in "--keep-hourly 3" ]; }; + + env-file = { + inherit passwordFile paths exclude; + initialize = true; + repository = "/home/alice/repos/env-file"; + environmentFile = "${pkgs.writeText "environmentFile" '' + SECRET=1234 + TOKEN=123456789ABcdEF + ''}"; + }; }; }; } diff --git a/tests/integration/standalone/restic.nix b/tests/integration/standalone/restic.nix index 0eada0921..c7e9fea68 100644 --- a/tests/integration/standalone/restic.nix +++ b/tests/integration/standalone/restic.nix @@ -271,6 +271,14 @@ in with subtest("Prune opts"): systemctl_succeed_as_alice("start restic-backups-prune-opts.service") + with subtest("Environment file"): + systemctl_succeed_as_alice("start restic-backups-env-file.service") + actual = succeed_as_alice("restic-env-file ls latest") + assert_list("restic-env-file ls latest", expectedIncluded, actual) + + assert "exclude" not in actual, \ + f"Paths containing \"*exclude*\" got backed up incorrectly. output: {actual}" + logout_alice() ''; }