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() ''; }