1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 03:29:45 +01:00

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:
David Terry 2020-12-23 22:13:05 +01:00 committed by Robert Helgesson
parent c12897e8e1
commit 1eb2dcf3a9
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
5 changed files with 82 additions and 10 deletions

View file

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

View file

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

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