1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2025-01-30 21:05:02 +01:00

himalaya: improve service

This commit is contained in:
Clément DOUIN 2024-04-19 11:38:48 +02:00 committed by Robert Helgesson
parent a042868557
commit 44ee9bc826
No known key found for this signature in database
GPG key ID: 96E745BD17AA17ED

View file

@ -130,16 +130,6 @@ in {
Extra environment variables to be exported in the service. Extra environment variables to be exported in the service.
''; '';
}; };
settings.account = lib.mkOption {
type = with lib.types; nullOr str;
default = null;
example = "personal";
description = ''
Name of the account the watcher should be started for.
If no account is given, the default one is used.
'';
};
}; };
accounts.email.accounts = lib.mkOption { accounts.email.accounts = lib.mkOption {
@ -171,24 +161,19 @@ in {
globalConfig = compactAttrs himalaya.settings; globalConfig = compactAttrs himalaya.settings;
allConfig = globalConfig // { accounts = accountsConfig; }; allConfig = globalConfig // { accounts = accountsConfig; };
in tomlFormat.generate "himalaya-config.toml" allConfig; in tomlFormat.generate "himalaya-config.toml" allConfig;
systemd.user.services = let
inherit (config.services.himalaya-watch) enable environment settings; systemd.user.services =
optionalArg = key: let inherit (config.services.himalaya-watch) enable environment;
if (key ? settings && !isNull settings."${key}") then
[ "--${key} ${settings."${key}"}" ]
else
[ ];
in { in {
himalaya-watch = lib.mkIf enable { "himalaya-watch@" = lib.mkIf enable {
Unit = { Unit = {
Description = "Email client Himalaya CLI envelopes watcher service"; Description = "Email client Himalaya CLI envelopes watcher service";
After = [ "network.target" ]; After = [ "network.target" ];
}; };
Install = { WantedBy = [ "default.target" ]; }; Install = { WantedBy = [ "default.target" ]; };
Service = { Service = {
ExecStart = lib.concatStringsSep " " ExecStart =
([ "${himalaya.package}/bin/himalaya" "envelopes" "watch" ] "${himalaya.package}/bin/himalaya envelopes watch --account %I";
++ optionalArg "account");
ExecSearchPath = "/bin"; ExecSearchPath = "/bin";
Environment = Environment =
lib.mapAttrsToList (key: val: "${key}=${val}") environment; lib.mapAttrsToList (key: val: "${key}=${val}") environment;