lieer: add path to notmuch config
This fetches the notmuch configuration path from the `NOTMUCH_CONFIG` session variable, if it is set. Specifically, this makes the lieer service find the configuration generated by the notmuch module.
This commit is contained in:
parent
c12897e8e1
commit
1eb2dcf3a9
|
@ -26,6 +26,8 @@ let
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
ExecStart = "${pkgs.gmailieer}/bin/gmi sync";
|
ExecStart = "${pkgs.gmailieer}/bin/gmi sync";
|
||||||
WorkingDirectory = account.maildir.absPath;
|
WorkingDirectory = account.maildir.absPath;
|
||||||
|
Environment = mkIf (config.home.sessionVariables ? NOTMUCH_CONFIG)
|
||||||
|
"NOTMUCH_CONFIG=${config.home.sessionVariables.NOTMUCH_CONFIG}";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,7 @@ with lib;
|
||||||
imports = [ ../../accounts/email-test-accounts.nix ];
|
imports = [ ../../accounts/email-test-accounts.nix ];
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
programs.notmuch.enable = true;
|
||||||
services.lieer.enable = true;
|
services.lieer.enable = true;
|
||||||
|
|
||||||
accounts.email.accounts = {
|
accounts.email.accounts = {
|
||||||
|
@ -24,6 +25,8 @@ with lib;
|
||||||
gmailieer = pkgs.writeScriptBin "dummy-gmailieer" "" // {
|
gmailieer = pkgs.writeScriptBin "dummy-gmailieer" "" // {
|
||||||
outPath = "@lieer@";
|
outPath = "@lieer@";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
notmuch = pkgs.writeScriptBin "dummy-notmuch" "";
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -32,7 +35,19 @@ with lib;
|
||||||
assertFileExists home-files/.config/systemd/user/lieer-hm-example-com.timer
|
assertFileExists home-files/.config/systemd/user/lieer-hm-example-com.timer
|
||||||
|
|
||||||
assertFileContent home-files/.config/systemd/user/lieer-hm-example-com.service \
|
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 \
|
assertFileContent home-files/.config/systemd/user/lieer-hm-example-com.timer \
|
||||||
${./lieer-service-expected.timer}
|
${./lieer-service-expected.timer}
|
||||||
'';
|
'';
|
60
tests/modules/services/lieer/account-without-notmuch.nix
Normal file
60
tests/modules/services/lieer/account-without-notmuch.nix
Normal file
|
@ -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}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
|
@ -1 +1,4 @@
|
||||||
{ lieer-service = ./lieer-service.nix; }
|
{
|
||||||
|
lieer-account-with-notmuch = ./account-with-notmuch.nix;
|
||||||
|
lieer-account-without-notmuch = ./account-without-notmuch.nix;
|
||||||
|
}
|
||||||
|
|
|
@ -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
|
|
Loading…
Reference in a new issue