Compare commits

...

1 commit

Author SHA1 Message Date
David Terry 1eb2dcf3a9
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.
2021-04-07 21:25:27 +02:00
5 changed files with 82 additions and 10 deletions

View file

@ -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}";
};
};
};

View file

@ -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}
'';

View 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}
'';
};
}

View file

@ -1 +1,4 @@
{ lieer-service = ./lieer-service.nix; }
{
lieer-account-with-notmuch = ./account-with-notmuch.nix;
lieer-account-without-notmuch = ./account-without-notmuch.nix;
}

View file

@ -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