Skip to content

Commit

Permalink
himalaya: add xdg desktop entry
Browse files Browse the repository at this point in the history
  • Loading branch information
soywod committed Apr 20, 2024
1 parent ed33f98 commit 5f8b176
Showing 1 changed file with 37 additions and 25 deletions.
62 changes: 37 additions & 25 deletions modules/programs/himalaya.nix
Original file line number Diff line number Diff line change
Expand Up @@ -154,32 +154,44 @@ in {
config = lib.mkIf himalaya.enable {
home.packages = [ himalaya.package ];

xdg.configFile."himalaya/config.toml".source = let
enabledAccounts = lib.filterAttrs (_: account: account.himalaya.enable)
config.accounts.email.accounts;
accountsConfig = lib.mapAttrs mkAccountConfig enabledAccounts;
globalConfig = compactAttrs himalaya.settings;
allConfig = globalConfig // { accounts = accountsConfig; };
in tomlFormat.generate "himalaya-config.toml" allConfig;

systemd.user.services =
xdg = {
configFile."himalaya/config.toml".source = let
enabledAccounts = lib.filterAttrs (_: account: account.himalaya.enable)
config.accounts.email.accounts;
accountsConfig = lib.mapAttrs mkAccountConfig enabledAccounts;
globalConfig = compactAttrs himalaya.settings;
allConfig = globalConfig // { accounts = accountsConfig; };
in tomlFormat.generate "himalaya-config.toml" allConfig;

desktopEntries.himalaya = {
type = "Application";
name = "himalaya";
genericName = "Email Client";
comment = "CLI to manage emails";
terminal = true;
exec = "himalaya %u";
categories = [ "Network" ];
mimeType = [ "x-scheme-handler/mailto" "message/rfc822" ];
settings = { Keywords = "email"; };
};
};

systemd.user.services."himalaya-watch@" =
let inherit (config.services.himalaya-watch) enable environment;
in {
"himalaya-watch@" = lib.mkIf enable {
Unit = {
Description = "Email client Himalaya CLI envelopes watcher service";
After = [ "network.target" ];
};
Install = { WantedBy = [ "default.target" ]; };
Service = {
ExecStart =
"${lib.getExe himalaya.package} envelopes watch --account %I";
ExecSearchPath = "/bin";
Environment =
lib.mapAttrsToList (key: val: "${key}=${val}") environment;
Restart = "always";
RestartSec = 10;
};
in lib.mkIf enable {
Unit = {
Description = "Email client Himalaya CLI envelopes watcher service";
After = [ "network.target" ];
};
Install = { WantedBy = [ "default.target" ]; };
Service = {
ExecStart =
"${lib.getExe himalaya.package} envelopes watch --account %I";
ExecSearchPath = "/bin";
Environment =
lib.mapAttrsToList (key: val: "${key}=${val}") environment;
Restart = "always";
RestartSec = 10;
};
};
};
Expand Down

0 comments on commit 5f8b176

Please sign in to comment.