From 58cef3796271aaeabaed98884d4abaab5d9d162d Mon Sep 17 00:00:00 2001 From: William Tan <1284324+Ninja3047@users.noreply.github.com> Date: Wed, 31 Jul 2024 02:27:17 -0400 Subject: [PATCH] nix-gc: remove extraneous quotes from shell script --- modules/services/nix-gc.nix | 6 +++--- tests/modules/services/nix-gc/basic.nix | 11 +++++++++++ tests/modules/services/nix-gc/nix-gc-script-expected | 2 ++ 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 tests/modules/services/nix-gc/nix-gc-script-expected diff --git a/modules/services/nix-gc.nix b/modules/services/nix-gc.nix index fe7e46698..50e8b6351 100644 --- a/modules/services/nix-gc.nix +++ b/modules/services/nix-gc.nix @@ -111,10 +111,10 @@ in { Unit = { Description = "Nix Garbage Collector"; }; Service = { Type = "oneshot"; - ExecStart = toString (pkgs.writeShellScript "nix-gc" '' - exec "${nixPackage}/bin/nix-collect-garbage ${ + ExecStart = toString (pkgs.writeShellScript "nix-gc" + "exec ${nixPackage}/bin/nix-collect-garbage ${ lib.optionalString (cfg.options != null) cfg.options - }"''); + }"); }; }; systemd.user.timers.nix-gc = { diff --git a/tests/modules/services/nix-gc/basic.nix b/tests/modules/services/nix-gc/basic.nix index 507c95985..a06b67238 100644 --- a/tests/modules/services/nix-gc/basic.nix +++ b/tests/modules/services/nix-gc/basic.nix @@ -25,5 +25,16 @@ timerFile=$(normalizeStorePaths $timerFile) assertFileContent $timerFile ${./expected.timer} + + nixgcScriptFile=$(grep -o \ + '/nix/store/.*-nix-gc' \ + $TESTED/home-files/.config/systemd/user/nix-gc.service + ) + + assertFileExists $nixgcScriptFile + + nixgcScriptFile=$(normalizeStorePaths $nixgcScriptFile) + + assertFileContent $nixgcScriptFile ${./nix-gc-script-expected} ''; } diff --git a/tests/modules/services/nix-gc/nix-gc-script-expected b/tests/modules/services/nix-gc/nix-gc-script-expected new file mode 100644 index 000000000..0ce2a4f91 --- /dev/null +++ b/tests/modules/services/nix-gc/nix-gc-script-expected @@ -0,0 +1,2 @@ +#!/nix/store/00000000000000000000000000000000-bash/bin/bash +exec @nix@/bin/nix-collect-garbage --delete-older-than 30d --max-freed $((64 * 1024**3))