diff --git a/modules/services/lieer.nix b/modules/services/lieer.nix index 571e2af7..eb419840 100644 --- a/modules/services/lieer.nix +++ b/modules/services/lieer.nix @@ -26,6 +26,8 @@ let Type = "oneshot"; ExecStart = "${pkgs.gmailieer}/bin/gmi sync"; WorkingDirectory = account.maildir.absPath; + Environment = mkIf (config.home.sessionVariables ? NOTMUCH_CONFIG) + "NOTMUCH_CONFIG=${config.home.sessionVariables.NOTMUCH_CONFIG}"; }; }; }; diff --git a/tests/modules/services/lieer/lieer-service.nix b/tests/modules/services/lieer/account-with-notmuch.nix similarity index 55% rename from tests/modules/services/lieer/lieer-service.nix rename to tests/modules/services/lieer/account-with-notmuch.nix index af3074b0..b6c85384 100644 --- a/tests/modules/services/lieer/lieer-service.nix +++ b/tests/modules/services/lieer/account-with-notmuch.nix @@ -6,6 +6,7 @@ with lib; imports = [ ../../accounts/email-test-accounts.nix ]; config = { + programs.notmuch.enable = true; services.lieer.enable = true; accounts.email.accounts = { @@ -24,6 +25,8 @@ with lib; gmailieer = pkgs.writeScriptBin "dummy-gmailieer" "" // { outPath = "@lieer@"; }; + + notmuch = pkgs.writeScriptBin "dummy-notmuch" ""; }) ]; @@ -32,7 +35,19 @@ with lib; assertFileExists home-files/.config/systemd/user/lieer-hm-example-com.timer assertFileContent home-files/.config/systemd/user/lieer-hm-example-com.service \ - ${./lieer-service-expected.service} + ${ + pkgs.writeText "lieer-service-expected.service" '' + [Service] + Environment=NOTMUCH_CONFIG=/home/hm-user/.config/notmuch/notmuchrc + ExecStart=@lieer@/bin/gmi sync + Type=oneshot + WorkingDirectory=/home/hm-user/Mail/hm@example.com + + [Unit] + ConditionPathExists=/home/hm-user/Mail/hm@example.com/.gmailieer.json + Description=lieer Gmail synchronization for hm@example.com + '' + } assertFileContent home-files/.config/systemd/user/lieer-hm-example-com.timer \ ${./lieer-service-expected.timer} ''; diff --git a/tests/modules/services/lieer/account-without-notmuch.nix b/tests/modules/services/lieer/account-without-notmuch.nix new file mode 100644 index 00000000..e2039551 --- /dev/null +++ b/tests/modules/services/lieer/account-without-notmuch.nix @@ -0,0 +1,60 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + imports = [ ../../accounts/email-test-accounts.nix ]; + + config = { + services.lieer.enable = true; + + accounts.email.accounts = { + "hm@example.com".lieer.enable = true; + "hm@example.com".lieer.sync.enable = true; + }; + + nixpkgs.overlays = [ + (self: super: { + gmailieer = pkgs.writeScriptBin "dummy-gmailieer" "" // { + outPath = "@lieer@"; + }; + }) + ]; + + test.asserts.warnings.expected = ['' + lieer is enabled for the following email accounts, but notmuch is not: + + hm@example.com + + Notmuch can be enabled with: + + accounts.email.accounts.hm@example.com.notmuch.enable = true; + + If you have configured notmuch outside of Home Manager, you can suppress this + warning with: + + programs.lieer.notmuchSetupWarning = false; + '']; + + nmt.script = '' + assertFileExists home-files/.config/systemd/user/lieer-hm-example-com.service + assertFileExists home-files/.config/systemd/user/lieer-hm-example-com.timer + + assertFileContent home-files/.config/systemd/user/lieer-hm-example-com.service \ + ${ + pkgs.writeText "lieer-service-expected.service" '' + [Service] + ExecStart=@lieer@/bin/gmi sync + Type=oneshot + WorkingDirectory=/home/hm-user/Mail/hm@example.com + + [Unit] + ConditionPathExists=/home/hm-user/Mail/hm@example.com/.gmailieer.json + Description=lieer Gmail synchronization for hm@example.com + '' + } + assertFileContent home-files/.config/systemd/user/lieer-hm-example-com.timer \ + ${./lieer-service-expected.timer} + ''; + }; +} diff --git a/tests/modules/services/lieer/default.nix b/tests/modules/services/lieer/default.nix index 1d6b435a..864c5f2e 100644 --- a/tests/modules/services/lieer/default.nix +++ b/tests/modules/services/lieer/default.nix @@ -1 +1,4 @@ -{ lieer-service = ./lieer-service.nix; } +{ + lieer-account-with-notmuch = ./account-with-notmuch.nix; + lieer-account-without-notmuch = ./account-without-notmuch.nix; +} diff --git a/tests/modules/services/lieer/lieer-service-expected.service b/tests/modules/services/lieer/lieer-service-expected.service deleted file mode 100644 index 1110e85c..00000000 --- a/tests/modules/services/lieer/lieer-service-expected.service +++ /dev/null @@ -1,8 +0,0 @@ -[Service] -ExecStart=@lieer@/bin/gmi sync -Type=oneshot -WorkingDirectory=/home/hm-user/Mail/hm@example.com - -[Unit] -ConditionPathExists=/home/hm-user/Mail/hm@example.com/.gmailieer.json -Description=lieer Gmail synchronization for hm@example.com