Commit 8cd4914

HPCesia <me@hpcesia.com>
2025-10-01 15:13:18
refactor: migrate thunderbird
1 parent 227510e
Changed files (4)
home
linux
gui
thunderbird
modules
home/linux/gui/thunderbird/default.nix
@@ -1,71 +0,0 @@
-{
-  pkgs,
-  pkgs-stable,
-  config,
-  lib,
-  myvars,
-  ...
-}: let
-  getThunderbirdAccountPath = accountName: profileName: let
-    accountId = builtins.hashString "sha256" accountName;
-    thunderbirdProfilesPath = ".thunderbird";
-  in "${config.home.homeDirectory}/${thunderbirdProfilesPath}/${profileName}/ImapMail/${accountId}";
-  thunderbird-x = pkgs-stable.thunderbird.overrideAttrs (oldAttrs: {
-    makeWrapperArgs = oldAttrs.makeWrapperArgs ++ ["--set" "MOZ_ENABLE_WAYLAND" "0"];
-  });
-in {
-  programs.thunderbird = {
-    enable = true;
-    package = thunderbird-x;
-    profiles.Default = {
-      isDefault = true;
-      settings = {
-        "extensions.autoDisableScopes" = 0;
-        "mail.spellcheck.inline" = false;
-      };
-    };
-  };
-
-  catppuccin.thunderbird.profile = "Default";
-
-  accounts.email.accounts = {
-    "${myvars.useremail}".thunderbird.enable = true;
-    "hpcesia@outlook.com".thunderbird.enable = true;
-  };
-
-  home.packages = with pkgs; [
-    birdtray
-  ];
-
-  xdg.configFile."birdtray-config.json" = {
-    force = true;
-    text = builtins.toJSON (
-      (builtins.fromJSON (builtins.readFile ./birdtray-default-config.json))
-      // {
-        accounts =
-          lib.mapAttrsToList (n: v: {
-            path = "${getThunderbirdAccountPath v.name "Default"}/INBOX.msf";
-          })
-          (lib.filterAttrs (n: v: v.thunderbird.enable) config.accounts.email.accounts);
-      }
-      // (lib.mapAttrs' (n: v: lib.nameValuePair "common/${n}" v) {
-        launchthunderbird = true;
-        exitthunderbirdonquit = true;
-        defaultcolor = "#c6a0f6"; # Catppucin Macchiato Mauve
-        hideWhenStartedManually = false;
-        hidewhenminimized = true;
-        hidewhenrestarted = true;
-        hidewhenstarted = true;
-        showhidethunderbird = true;
-        restartthunderbird = true;
-        startClosedThunderbird = true;
-      })
-      // (lib.mapAttrs' (n: v: lib.nameValuePair "advanced/${n}" v) {
-        tbcmdline = [(lib.getExe thunderbird-x)];
-        tbwindowmatch = "Thunderbird";
-        updateOnStartup = false;
-        unreadopacitylevel = 0.80;
-      })
-    );
-  };
-}
modules/desktop/apps/thunderbird/bird-tray.nix
@@ -0,0 +1,54 @@
+{lib, ...}: {
+  flake.modules.homeManager.desktop = {
+    pkgs,
+    config,
+    ...
+  }: let
+    getThunderbirdAccountPath = accountName: profileName: let
+      accountId = builtins.hashString "sha256" accountName;
+      thunderbirdProfilesPath = ".thunderbird";
+    in "${config.home.homeDirectory}/${thunderbirdProfilesPath}/${profileName}/ImapMail/${accountId}";
+    thunderbird-x = pkgs.thunderbird.overrideAttrs (oldAttrs: {
+      makeWrapperArgs = oldAttrs.makeWrapperArgs ++ ["--set" "MOZ_ENABLE_WAYLAND" "0"];
+    });
+  in
+    lib.mkIf pkgs.stdenv.hostPlatform.isLinux {
+      programs.thunderbird.package = thunderbird-x;
+
+      home.packages = with pkgs; [
+        birdtray
+      ];
+
+      xdg.configFile."birdtray-config.json" = {
+        force = true;
+        text = builtins.toJSON (
+          (builtins.fromJSON (builtins.readFile ./birdtray-default-config.json))
+          // {
+            accounts =
+              lib.mapAttrsToList (n: v: {
+                path = "${getThunderbirdAccountPath v.name "Default"}/INBOX.msf";
+              })
+              (lib.filterAttrs (n: v: v.thunderbird.enable) config.accounts.email.accounts);
+          }
+          // (lib.mapAttrs' (n: v: lib.nameValuePair "common/${n}" v) {
+            launchthunderbird = true;
+            exitthunderbirdonquit = true;
+            defaultcolor = "#c6a0f6"; # Catppucin Macchiato Mauve
+            hideWhenStartedManually = false;
+            hidewhenminimized = true;
+            hidewhenrestarted = true;
+            hidewhenstarted = true;
+            showhidethunderbird = true;
+            restartthunderbird = true;
+            startClosedThunderbird = true;
+          })
+          // (lib.mapAttrs' (n: v: lib.nameValuePair "advanced/${n}" v) {
+            tbcmdline = [(lib.getExe thunderbird-x)];
+            tbwindowmatch = "Thunderbird";
+            updateOnStartup = false;
+            unreadopacitylevel = 0.80;
+          })
+        );
+      };
+    };
+}
home/linux/gui/thunderbird/birdtray-default-config.json → modules/desktop/apps/thunderbird/birdtray-default-config.json
File renamed without changes
modules/desktop/apps/thunderbird/default.nix
@@ -0,0 +1,16 @@
+{
+  flake.modules.homeManager.desktop = _: {
+    programs.thunderbird = {
+      enable = true;
+      profiles.Default = {
+        isDefault = true;
+        settings = {
+          "extensions.autoDisableScopes" = 0;
+          "mail.spellcheck.inline" = false;
+        };
+      };
+    };
+
+    catppuccin.thunderbird.profile = "Default";
+  };
+}