From 6c6314877485a8092e5462268b996a9041d72b35 Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Tue, 3 Oct 2023 07:59:00 +0100 Subject: [PATCH] Make more account activation dependency links Link more calendar/contact accounts with relevant email Link services to expressions required Disable ukaea email by default, enable on work laptop --- home/accounts/calendar.nix | 31 +++++++------- home/accounts/contact.nix | 28 ++++++------ home/accounts/email.nix | 88 +++++++++++++++++++------------------- hosts/Ronin/home.nix | 16 +++---- 4 files changed, 80 insertions(+), 83 deletions(-) diff --git a/home/accounts/calendar.nix b/home/accounts/calendar.nix index 5dbb58ca..0253daec 100644 --- a/home/accounts/calendar.nix +++ b/home/accounts/calendar.nix @@ -8,14 +8,16 @@ services.vdirsyncer.enable = true; accounts.calendar = { basePath = ".calendar"; - accounts = { - nextcloud = { + accounts = let + local = { + type = "filesystem"; + fileExt = ".ics"; + }; + in { + nextcloud = rec { + inherit local; primary = lib.mkDefault true; primaryCollection = "Personal"; - local = { - type = "filesystem"; - fileExt = ".ics"; - }; remote = { type = "caldav"; url = "https://cloud.xenia.me.uk/remote.php/dav"; @@ -33,30 +35,27 @@ metadata = [ "color" "displayname" ]; }; khal = { - enable = lib.mkDefault true; + inherit (vdirsyncer) enable; type = "discover"; }; }; - ukaea = { + ukaea = let emailConfig = config.accounts.email.accounts.ukaea; + in rec { + inherit local; primaryCollection = "Calendar"; - local = { - type = "filesystem"; - fileExt = ".ics"; - }; remote = rec { - inherit (config.accounts.email.accounts.ukaea) - userName passwordCommand; + inherit (emailConfig) userName passwordCommand; type = "caldav"; url = "http://localhost:1080/users/${userName}/calendar/"; }; vdirsyncer = { - enable = lib.mkDefault true; + enable = lib.mkDefault emailConfig.mbsync.enable; collections = [ "from a" ]; metadata = [ "color" "displayname" ]; itemTypes = [ "VEVENT" ]; }; khal = { - enable = lib.mkDefault true; + inherit (vdirsyncer) enable; type = "discover"; }; }; diff --git a/home/accounts/contact.nix b/home/accounts/contact.nix index b744b5ea..e1f024b7 100644 --- a/home/accounts/contact.nix +++ b/home/accounts/contact.nix @@ -5,37 +5,35 @@ programs.vdirsyncer.enable = true; accounts.contact = { basePath = ".contact"; - accounts = { + accounts = let + calendarAccounts = config.accounts.calendar.accounts; + local = { + type = "filesystem"; + fileExt = ".vcf"; + }; + in { nextcloud = { - local = { - type = "filesystem"; - fileExt = ".vcf"; - }; + inherit local; remote = { - inherit (config.accounts.calendar.accounts.nextcloud.remote) - userName passwordCommand; + inherit (calendarAccounts.nextcloud.remote) userName passwordCommand; type = "carddav"; url = "https://cloud.xenia.me.uk/remote.php/dav/addressbooks/users/xenia/contacts-1/"; }; vdirsyncer = { - enable = lib.mkDefault true; + inherit (calendarAccounts.nextcloud.vdirsyncer) enable; collections = [ "from a" ]; }; }; ukaea = { - local = { - type = "filesystem"; - fileExt = ".vcf"; - }; + inherit local; remote = rec { - inherit (config.accounts.calendar.accounts.ukaea.remote) - userName passwordCommand; + inherit (calendarAccounts.ukaea.remote) userName passwordCommand; type = "carddav"; url = "http://localhost:1080/users/${userName}/contacts/"; }; vdirsyncer = { - enable = lib.mkDefault true; + inherit (calendarAccounts.ukaea.vdirsyncer) enable; collections = [ "from a" ]; }; }; diff --git a/home/accounts/email.nix b/home/accounts/email.nix index 344178cf..2216ddf3 100644 --- a/home/accounts/email.nix +++ b/home/accounts/email.nix @@ -107,7 +107,7 @@ ukaea = let host = "127.0.0.1"; tls.enable = false; - accountEnabled = true; + accountEnabled = false; in rec { inherit realName; primary = lib.mkDefault false; @@ -156,56 +156,56 @@ }; }; }; - systemd.user.services = { - imapnotify-proton.Unit = { + systemd.user.services = let emailAccounts = config.accounts.email.accounts; + in { + imapnotify-proton.Unit = lib.mkIf emailAccounts.proton.imapnotify.enable { Wants = [ "protonmail-bridge.service" ]; After = [ "protonmail-bridge.service" ]; }; - imapnotify-ukaea.Unit = { + imapnotify-ukaea.Unit = lib.mkIf emailAccounts.ukaea.imapnotify.enable { Wants = [ "davmail.service" ]; After = [ "davmail.service" ]; }; - protonmail-bridge = - lib.mkIf config.accounts.email.accounts.proton.mbsync.enable { - Unit = { - Description = "Podman container-protonmail-bridge.service"; - Documentation = [ "man:podman-generate-systemd(1)" ]; - Wants = [ "network-online.target" ]; - After = [ "network-online.target" ]; - RequiresMountsFor = "%t/containers"; - }; - Service = { - Environment = - [ "PODMAN_SYSTEMD_UNIT=%n" "PATH=/run/wrappers/bin/:$PATH" ]; - Restart = "always"; - TimeoutStopSec = 70; - ExecStart = '' - ${pkgs.podman}/bin/podman run \ - --cidfile=%t/%n.ctr-id \ - --cgroups=no-conmon \ - --rm \ - --sdnotify=conmon \ - --replace \ - -d \ - --name=protonmail-bridge \ - -v protonmail:/root \ - -p 127.0.0.1:1025:25/tcp \ - -p 127.0.0.1:1143:143/tcp shenxn/protonmail-bridge''; - ExecStop = '' - ${pkgs.podman}/bin/podman stop \ - --ignore -t 10 \ - --cidfile=%t/%n.ctr-id''; - ExecStopPost = '' - ${pkgs.podman}/bin/podman rm \ - -f \ - --ignore -t 10 \ - --cidfile=%t/%n.ctr-id''; - Type = "notify"; - NotifyAccess = "all"; - }; - Install.WantedBy = [ "default.target" ]; + protonmail-bridge = lib.mkIf emailAccounts.proton.mbsync.enable { + Unit = { + Description = "Podman container-protonmail-bridge.service"; + Documentation = [ "man:podman-generate-systemd(1)" ]; + Wants = [ "network-online.target" ]; + After = [ "network-online.target" ]; + RequiresMountsFor = "%t/containers"; }; - davmail = lib.mkIf config.accounts.email.accounts.ukaea.mbsync.enable { + Service = { + Environment = + [ "PODMAN_SYSTEMD_UNIT=%n" "PATH=/run/wrappers/bin/:$PATH" ]; + Restart = "always"; + TimeoutStopSec = 70; + ExecStart = '' + ${pkgs.podman}/bin/podman run \ + --cidfile=%t/%n.ctr-id \ + --cgroups=no-conmon \ + --rm \ + --sdnotify=conmon \ + --replace \ + -d \ + --name=protonmail-bridge \ + -v protonmail:/root \ + -p 127.0.0.1:1025:25/tcp \ + -p 127.0.0.1:1143:143/tcp shenxn/protonmail-bridge''; + ExecStop = '' + ${pkgs.podman}/bin/podman stop \ + --ignore -t 10 \ + --cidfile=%t/%n.ctr-id''; + ExecStopPost = '' + ${pkgs.podman}/bin/podman rm \ + -f \ + --ignore -t 10 \ + --cidfile=%t/%n.ctr-id''; + Type = "notify"; + NotifyAccess = "all"; + }; + Install.WantedBy = [ "default.target" ]; + }; + davmail = lib.mkIf emailAccounts.ukaea.mbsync.enable { Unit = { Description = "Davmail server"; Wants = [ "network-online.target" "graphical-session.target" ]; diff --git a/hosts/Ronin/home.nix b/hosts/Ronin/home.nix index db65fea5..9925d1e9 100644 --- a/hosts/Ronin/home.nix +++ b/hosts/Ronin/home.nix @@ -24,15 +24,15 @@ accounts = { email.accounts = { proton.primary = false; - ukaea.primary = true; - }; - calendar.accounts.nextcloud = { - vdirsyncer.enable = false; # TEMP until fixed - khal.enable = false; # TEMP until fixed - }; - contact.accounts.nextcloud = { - vdirsyncer.enable = false; # TEMP until fixed + ukaea = { + primary = true; + imapnotify.enable = true; + mbsync.enable = true; + msmtp.enable = true; + mu.enable = true; + }; }; + calendar.accounts.nextcloud.vdirsyncer.enable = false; # TEMP until fixed }; services.vdirsyncer.enable = lib.mkForce false; # TEMP until fixed services.kanshi.profiles = {