himalaya: improve service
This commit is contained in:
parent
ff1c364654
commit
1251ef424a
|
@ -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,31 +161,26 @@ 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
|
in {
|
||||||
[ "--${key} ${settings."${key}"}" ]
|
"himalaya-watch@" = lib.mkIf enable {
|
||||||
else
|
Unit = {
|
||||||
[ ];
|
Description = "Email client Himalaya CLI envelopes watcher service";
|
||||||
in {
|
After = [ "network.target" ];
|
||||||
himalaya-watch = lib.mkIf enable {
|
};
|
||||||
Unit = {
|
Install = { WantedBy = [ "default.target" ]; };
|
||||||
Description = "Email client Himalaya CLI envelopes watcher service";
|
Service = {
|
||||||
After = [ "network.target" ];
|
ExecStart =
|
||||||
};
|
"${himalaya.package}/bin/himalaya envelopes watch --account %I";
|
||||||
Install = { WantedBy = [ "default.target" ]; };
|
ExecSearchPath = "/bin";
|
||||||
Service = {
|
Environment =
|
||||||
ExecStart = lib.concatStringsSep " "
|
lib.mapAttrsToList (key: val: "${key}=${val}") environment;
|
||||||
([ "${himalaya.package}/bin/himalaya" "envelopes" "watch" ]
|
Restart = "always";
|
||||||
++ optionalArg "account");
|
RestartSec = 10;
|
||||||
ExecSearchPath = "/bin";
|
};
|
||||||
Environment =
|
|
||||||
lib.mapAttrsToList (key: val: "${key}=${val}") environment;
|
|
||||||
Restart = "always";
|
|
||||||
RestartSec = 10;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue