diff --git a/hosts/helix-texta.nix b/hosts/helix-texta.nix index d6b6334..04e8d48 100644 --- a/hosts/helix-texta.nix +++ b/hosts/helix-texta.nix @@ -199,6 +199,11 @@ in { mode = "0400"; key = "restic-backup"; }; + sops.secrets."radicale-password" = { + sopsFile = ../secrets/users/malte/secrets.yaml; + owner = "malte"; + mode = "0400"; + }; # This value determines the NixOS release from which the default # settings for stateful data, like file locations and database versions diff --git a/hosts/murex-pecten.nix b/hosts/murex-pecten.nix index d51d5ba..a01f46a 100644 --- a/hosts/murex-pecten.nix +++ b/hosts/murex-pecten.nix @@ -204,6 +204,11 @@ mode = "0400"; key = "restic-backup"; }; + sops.secrets."radicale-password" = { + sopsFile = ../secrets/users/malte/secrets.yaml; + owner = "malte"; + mode = "0400"; + }; environment.systemPackages = with pkgs; [ qt5.qtwayland diff --git a/secrets/users/malte/secrets.yaml b/secrets/users/malte/secrets.yaml index 5f41207..dd8eede 100644 --- a/secrets/users/malte/secrets.yaml +++ b/secrets/users/malte/secrets.yaml @@ -1,4 +1,5 @@ restic-backup: ENC[AES256_GCM,data:X5c67BwnXXXbb1z4qWknWLqNYoLySZq8KVMj4olpzkqGsnA=,iv:vsbBBlg2gU1jCTlvqDfHnvXalbKRw6f3pijNvkXaP+0=,tag:35NUoukReCjBsZLn1pDvoQ==,type:str] +radicale-password: ENC[AES256_GCM,data:9v2Lp9LoDD3sDzCoVrjaVEJ8DeyJkPMzvqYqq+3WgPc=,iv:A0CbD+snrQsuJONFpINXMRc7U/TB+sokWJg3KpnxFlI=,tag:zwl5GQAjDujNWwPskBuHaw==,type:str] sops: kms: [] gcp_kms: [] @@ -23,8 +24,8 @@ sops: bnNOU1JjWnhaSSs3dnNpYjVUaVBYZlUKnRYzc7ipD07fgnIGDbAKdEqc1YpNLPsZ FpDLiSGDHo+dZXis9hspW7GdfhYr58aciTmhpSILU0GA7M9D3I3N2A== -----END AGE ENCRYPTED FILE----- - lastmodified: "2022-01-14T09:50:53Z" - mac: ENC[AES256_GCM,data:IPjqm5bjJVPV2yOG78uxtQHH0AXnkqRoybovQDowmW23OXCU9mW3jsvuXFDIBd1A6D/3a3v3uu46BDUC6yg3HNvi2hpJlOCbk0PKkk2IeVspWAGi5CiOiXfJzfDKl2MIY3LiGSAJ74wy00JTCk1jvHcMeFjDy5ojmPkJGkYepQs=,iv:I3wQrxzT+jCFauLtNllkSAkH7Aep4bPoS2menEFGSz4=,tag:PsiMtUNdoOwHN1i+MW/kpg==,type:str] + lastmodified: "2022-03-22T17:09:30Z" + mac: ENC[AES256_GCM,data:LrEFMz6EaRoVxjwbiH/ZL1SWfMovHkFVgA9dQj4UvE0fEmkG2amLvtbUeLucO7cwLGbAZKLdVFyb/kHmBGImcNovEyECAgMtwzbvORnBHsbsTP7awCXxUBF8zXCUPyOutjku+of53c6aWUhoFAl9Fiiz64R9+cHhaXbIgr4sCBI=,iv:eDStOAZBGwm45/LA3isvI+jMTbWZsgQYC+KZ0FJOCWA=,tag:Cm6hIaEkYpgnh0ZBfaIKCg==,type:str] pgp: - created_at: "2022-01-14T09:50:37Z" enc: | @@ -47,4 +48,4 @@ sops: -----END PGP MESSAGE----- fp: 71E08E591553F5EA4CB98745BCE9E4BF632E7CED unencrypted_suffix: _unencrypted - version: 3.7.1 + version: 3.7.2 diff --git a/users/malte/home.nix b/users/malte/home.nix index b59de36..cff472e 100644 --- a/users/malte/home.nix +++ b/users/malte/home.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, config, ... }: +{ pkgs, lib, config, nixosConfig, ... }: let @@ -49,13 +49,13 @@ in { ./zathura.nix ./taskwarrior.nix ./scarlett-solo.nix - ./khal.nix ./cataclysm-dda.nix ./kakoune.nix ./colors.nix ./mpv.nix ./broot.nix ../modules/restic-backup.nix + ../modules/synchronize-calendars.nix ]; config = { @@ -181,6 +181,14 @@ in { ]; }; + # Configure calendar synchronization + services.synchronize-calendars = { + enable = true; + user = "malte"; + passwordFile = nixosConfig.sops.secrets."radicale-password".path; + defaultCalendar = "Malte"; + }; + fonts.fontconfig.enable = true; services.mpris-proxy.enable = true; diff --git a/users/malte/khal.nix b/users/modules/synchronize-calendars.nix similarity index 50% rename from users/malte/khal.nix rename to users/modules/synchronize-calendars.nix index 440baf2..30ca85c 100644 --- a/users/malte/khal.nix +++ b/users/modules/synchronize-calendars.nix @@ -1,7 +1,10 @@ -{ pkgs, ... }: +# Synchronize calendars from https://cal.tammena.rocks + +{ pkgs, lib, config, ... }: let - defaultCalendar = "Malte"; + cfg = config.services.synchronize-calendars; + khalConfig = '' [calendars] @@ -17,8 +20,9 @@ let longdatetimeformat = %d.%m.%Y %H:%M [default] - default_calendar = ${defaultCalendar} + default_calendar = ${cfg.defaultCalendar} ''; + vdirsyncerConfig = '' [general] status_path = "~/.local/state/vdirsyncer/status/" @@ -37,25 +41,39 @@ let [storage caltammenarocks] type = "caldav" - url = "https://cal.tammena.rocks/malte/" - username = "malte" - password.fetch = ["command", "${pkgs.pass}/bin/pass", "show", "Server/Radicale/malte"] + url = "https://cal.tammena.rocks/${cfg.user}/" + username = "${cfg.user}" + password.fetch = ["command", "cat", "${cfg.passwordFile}"] ''; in { - home.packages = [ pkgs.vdirsyncer ]; + options.services.synchronize-calendars = with lib; { + enable = mkEnableOption "Enable service to synchronize my calendars and add some necessary programs"; + + user = mkOption { + type = types.str; + description = "Radicale user"; + }; + + passwordFile = mkOption { + type = types.str; + description = "File containing the Radicale password for user"; + }; + + defaultCalendar = mkOption { + type = types.str; + description = "Default calendar to use in khal"; + }; + }; + + config = lib.mkIf cfg.enable { + home.packages = [ pkgs.vdirsyncer pkgs.khal ]; # == Systemd settings to automatically run the sync == systemd.user.services."synchronize-calendars" = { - Unit = { - Description = "Synchronize my calendars using vdirsyncer"; - Requisite = "dev-yubikey.device"; - After = "dev-yubikey.device"; - }; + Unit.Description = "Synchronize my calendars using vdirsyncer"; Service = { Type = "oneshot"; - Environment = - [ "PASSWORD_STORE_DIR=/home/malte/.local/share/password-store" ]; ExecStart = '' ${pkgs.vdirsyncer}/bin/vdirsyncer sync ''; @@ -63,14 +81,13 @@ in { }; systemd.user.timers."synchronize-calendars" = { - Unit = { - Description = "Run synchronize-calendars.service every 15 minutes"; - }; - Timer = { OnCalendar = "*:0/10"; }; - Install = { WantedBy = [ "timers.target" ]; }; + Unit.Description = "Run synchronize-calendars.service every 15 minutes"; + Timer.OnCalendar = "*:0/10"; + Install.WantedBy = [ "timers.target" ]; }; # == Configuration == xdg.configFile."khal/config".text = khalConfig; xdg.configFile."vdirsyncer/config".text = vdirsyncerConfig; + }; }