Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Managing Thunderbird calendars with accounts.calendars? #5775

Open
griffi-gh opened this issue Aug 27, 2024 · 4 comments
Open

Managing Thunderbird calendars with accounts.calendars? #5775

griffi-gh opened this issue Aug 27, 2024 · 4 comments
Assignees

Comments

@griffi-gh
Copy link

griffi-gh commented Aug 27, 2024

Description

It would be helpful to have an option to configure Thunderbird calendar accounts using accounts.calendars.accounts.<name>.* options.

Seems like currently, only vdirsyncer and khal are suppported?

@l0b0
Copy link

l0b0 commented Oct 6, 2024

I was able to configure the calendar specified as "myAccount" like this:

{
  home-manager.users.default.programs.thunderbird.settings =
    let
      calendarAccount = config.home-manager.users.default.accounts.calendar.accounts.myAccount;
      safeName = builtins.replaceStrings [ "." ] [ "-" ];
      calendarAccountSafeName = safeName calendarAccount.name;
    in
    {
      "calendar.registry.${calendarAccountSafeName}.cache.enabled" = true;
      "calendar.registry.${calendarAccountSafeName}.calendar-main-default" = calendarAccount.primary;
      "calendar.registry.${calendarAccountSafeName}.calendar-main-in-composite" = calendarAccount.primary;
      "calendar.registry.${calendarAccountSafeName}.name" = calendarAccount.name;
      "calendar.registry.${calendarAccountSafeName}.type" = "caldav";
      "calendar.registry.${calendarAccountSafeName}.uri" = calendarAccount.remote.url;
      "calendar.registry.${calendarAccountSafeName}.username" = calendarAccount.remote.userName;
    };
}

@l0b0
Copy link

l0b0 commented Oct 6, 2024

Looks like there's already a PR for this functionality.

@l0b0
Copy link

l0b0 commented Oct 8, 2024

With HTTP type calendar support:

    programs.thunderbird.settings =
      let
        safeName = builtins.replaceStrings [ "." ] [ "-" ];
        calendarRegistryEntry =
          calendarAccount:
          let
            calendarAccountSafeName = safeName calendarAccount.name;
          in
          {
            "calendar.registry.${calendarAccountSafeName}.cache.enabled" = true;
            "calendar.registry.${calendarAccountSafeName}.calendar-main-default" = calendarAccount.primary;
            "calendar.registry.${calendarAccountSafeName}.calendar-main-in-composite" = true;
            "calendar.registry.${calendarAccountSafeName}.name" = calendarAccount.name;
            "calendar.registry.${calendarAccountSafeName}.uri" = calendarAccount.remote.url;
            "calendar.registry.${calendarAccountSafeName}.username" = calendarAccount.remote.userName;
          }
          // {
            "caldav" = {
              "calendar.registry.${calendarAccountSafeName}.type" = "caldav";
            };
            "http" = {
              "calendar.registry.${calendarAccountSafeName}.type" = "ics";
              "calendar.registry.${calendarAccountSafeName}.readOnly" = true;
            };
          }
          ."${calendarAccount.remote.type}";
        contactsAccount = config.home-manager.users.default.accounts.contact.accounts."my.account";
        contactsAccountSafeName = safeName contactsAccount.name;
      in
      lib.attrsets.concatMapAttrs (
        _name: calendarRegistryEntry
      ) config.home-manager.users.default.accounts.calendar.accounts
      // {
        "ldap_2.servers.${contactsAccountSafeName}.carddav.url" = contactsAccount.remote.url;
        "ldap_2.servers.${contactsAccountSafeName}.carddav.username" = contactsAccount.remote.userName;
        "ldap_2.servers.${contactsAccountSafeName}.description" = contactsAccount.name;
        "ldap_2.servers.${contactsAccountSafeName}.dirType" = 102;
        "ldap_2.servers.${contactsAccountSafeName}.filename" = "abook-${contactsAccountSafeName}.sqlite";
      };

@felbinger
Copy link

For multiple accounts, in case someone else needs this too:

{
    programs.thunderbird.settings =
      let
      cal = map (calendar: let
        safeName = builtins.replaceStrings [ "." ] [ "-" ] calendar.name;
        in {
          "calendar.registry.${safeName}.cache.enabled" = true;
          "calendar.registry.${safeName}.calendar-main-default" = calendar.primary;
          "calendar.registry.${safeName}.calendar-main-in-composite" = calendar.primary;
          "calendar.registry.${safeName}.name" = calendar.name;
          "calendar.registry.${safeName}.type" = "caldav";
          "calendar.registry.${safeName}.uri" = calendar.remote.url;
          "calendar.registry.${safeName}.username" = calendar.remote.userName;
        }) (builtins.attrValues config.accounts.calendar.accounts);
      in builtins.foldl' lib.recursiveUpdate { } cal;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants