migrate vdirsync + khal

Home-Manager got first level support for calendars and contacts.
Provided integrations are vdirsync and khal which I'm already using.
I therefore migrate from my own setup to the upstream setup.

Issue on home-manager project:
https://github.com/nix-community/home-manager/issues/2335
This commit is contained in:
Daniel Siepmann 2023-06-13 10:46:58 +02:00
parent 4fd157655c
commit 0f6e71321e
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
9 changed files with 33 additions and 192 deletions

1
.gitattributes vendored
View file

@ -1,3 +1,4 @@
home/accounts.nix filter=git-crypt diff=git-crypt
home/programs/firefox/userContent.css filter=git-crypt diff=git-crypt
home/programs/firefox/clientSpecific.css filter=git-crypt diff=git-crypt
home/programs/ssh-match-blocks.nix filter=git-crypt diff=git-crypt

View file

@ -7,18 +7,13 @@ in {
imports = [
./home/modules/programs/cmus.nix
./home/modules/programs/vdirsyncer.nix
./home/modules/programs/khal.nix
./home/modules/programs/khal-notification.nix
./home/modules/programs/languagetool.nix
./home/modules/programs/mailhog.nix
./home/modules/programs/my-pidgin.nix
];
disabledModules = [
# As I already have my own vdirsyncer and khal.
# TODO: Migrate to upstream module
"programs/vdirsyncer.nix"
"programs/khal.nix"
];
home = {
@ -50,6 +45,10 @@ in {
targets.genericLinux.enable = true;
accounts = import ./home/accounts.nix {
inherit config pkgs;
};
nix = import ./home/programs/nix.nix {
inherit pkgs;
};

BIN
home/accounts.nix Normal file

Binary file not shown.

View file

@ -27,15 +27,7 @@ let
in {
options.programs.khal = {
enable = mkEnableOption "khal";
package = mkOption {
type = types.package;
default = pkgs.khal;
description = "khal package to install.";
};
frequency = mkOption {
notificationFrequency = mkOption {
type = types.str;
default = "*:0/15";
example = "hourly";
@ -45,37 +37,24 @@ in {
'';
};
time_delta = mkOption {
notificationTimeDelta = mkOption {
type = types.str;
default = "15m";
example = "15m";
description = "The delta to pass to khal list.";
};
configuration = mkOption {
type = types.str;
default = "";
description = ''
The content of the configuration file.
See: https://lostpackets.de/khal/configure.html
'';
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
xdg.configFile."khal/config".text = cfg.configuration;
systemd.user.services.khal_notification = {
Unit = { Description = "khal notification"; };
Service = { ExecStart = "${notificationScript}/bin/khal-notification \"${cfg.time_delta}\""; };
Service = { ExecStart = "${notificationScript}/bin/khal-notification \"${cfg.notificationTimeDelta}\""; };
};
systemd.user.timers.khal_notification = {
Unit = { Description = "khal notification"; };
Timer = {
OnCalendar = "${cfg.frequency}";
OnCalendar = "${cfg.notificationFrequency}";
Unit = "khal_notification.service";
};
Install = { WantedBy = [ "timers.target" ]; };

View file

@ -1,60 +0,0 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.vdirsyncer;
in {
options.programs.vdirsyncer = {
enable = mkEnableOption "vdirsyncer";
package = mkOption {
type = types.package;
default = pkgs.vdirsyncer;
description = "vdirsyncer package to install.";
};
frequency = mkOption {
type = types.str;
default = "*:0/15";
example = "hourly";
description = ''
The sync frequency.
Check <literal>man systemd.time</literal> for more information on the syntax.
'';
};
configuration = mkOption {
type = types.str;
default = "";
description = ''
The content of the configuration file.
See:
- https://vdirsyncer.pimutils.org/en/stable/tutorial.html#configuration
- https://github.com/pimutils/vdirsyncer/blob/main/config.example
'';
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
xdg.configFile."vdirsyncer/config".text = cfg.configuration;
systemd.user.services.vdirsyncer = {
Unit = { Description = "vdirsyncer synchronisation"; };
Service = { ExecStart = "${pkgs.vdirsyncer}/bin/vdirsyncer sync"; };
};
systemd.user.timers.vdirsyncer = {
Unit = { Description = "vdirsyncer synchronisation"; };
Timer = {
OnBootSec = "15min";
OnCalendar = "${cfg.frequency}";
Persistent = true;
Unit = "vdirsyncer.service";
};
Install = { WantedBy = [ "timers.target" ]; };
};
};
}

View file

@ -54,9 +54,7 @@ in {
inherit pkgs ownLib;
};
vdirsyncer = import ./programs/vdirsyncer.nix {
inherit config pkgs;
};
vdirsyncer.enable = true;
khal = import ./programs/khal.nix {
inherit config;
};

View file

@ -3,34 +3,11 @@
{
enable = true;
frequency = "*-*-* *:14,29,44,59:00";
time_delta = "16m";
notificationFrequency = "*-*-* *:14,29,44,59:00";
notificationTimeDelta = "16m";
configuration = ''
[calendars]
[[private]]
path = ${config.xdg.dataHome}/vdir/calendars/private/personal
color = dark blue
[[arbeit]]
path = ${config.xdg.dataHome}/vdir/calendars/private/imported-arbeitics
color = dark red
[[birthdays]]
path = ${config.xdg.dataHome}/vdir/calendars/private/contact_birthdays
color = dark green
[[typo3]]
path = ${config.xdg.dataHome}/vdir/calendars/private/typo3
color = #FFE377
[[work]]
path = ${config.xdg.dataHome}/vdir/calendars/company/personal
color = dark red
[[sac_scrum_team]]
path = ${config.xdg.dataHome}/vdir/calendars/company/sac-scrum-team-synced
color = dark red
[locale]
local_timezone= Europe/Berlin
default_timezone= Europe/Berlin
'';
locale = {
default_timezone = "Europe/Berlin";
local_timezone = "Europe/Berlin";
};
}

View file

@ -1,58 +0,0 @@
{ pkgs, config }:
{
enable = true;
frequency = "Mon..Thu *-*-* 15,12,8:00";
# Run `vdirsyncer discover <name>` after adding a new pair
configuration = ''
[general]
status_path = "${config.xdg.dataHome}/vdirsyncer/status/"
[pair private_calendar]
a = "private_calendar_local"
b = "private_calendar_remote"
collections = ["from a", "from b"]
[storage private_calendar_local]
type = "filesystem"
path = "${config.xdg.dataHome}/vdir/calendars/private/"
fileext = ".ics"
[storage private_calendar_remote]
type = "caldav"
url = "https://nextcloud.daniel-siepmann.de/remote.php/dav"
username = "dsiepmann"
password.fetch = ["command", "${pkgs.libsecret}/bin/secret-tool", "lookup", "account", "app-dsiepmann@nextcloud.daniel-siepmann.de"]
start_date = "datetime.now() - timedelta(days=60)"
end_date = "datetime.now() + timedelta(days=365)"
[pair company_calendar]
a = "company_calendar_local"
b = "company_calendar_remote"
collections = ["from a", "from b"]
[storage company_calendar_local]
type = "filesystem"
path = "${config.xdg.dataHome}/vdir/calendars/company/"
fileext = ".ics"
[storage company_calendar_remote]
type = "caldav"
url = "https://nextcloud.codappix.com/remote.php/dav"
username = "daniel.siepmann"
password.fetch = ["command", "${pkgs.libsecret}/bin/secret-tool", "lookup", "account", "app-dsiepmann@nextcloud.codappix.com"]
start_date = "datetime.now() - timedelta(days=60)"
end_date = "datetime.now() + timedelta(days=365)"
[pair sac_team]
a = "sac_team_calendar_local"
b = "sac_team_calendar_remote"
collections = null
[storage sac_team_calendar_local]
type = "filesystem"
path = "${config.xdg.dataHome}/vdir/calendars/sac_team/"
fileext = ".ics"
[storage sac_team_calendar_remote]
type = "http"
url = "https://calendar.google.com/calendar/ical/0ks410dho8f5ohcik361i4c2bs%40group.calendar.google.com/public/basic.ics"
'';
}

View file

@ -2,17 +2,22 @@
{
dunst = import ./services/dunst.nix {
inherit config;
};
dunst = import ./services/dunst.nix {
inherit config;
};
gpg-agent = import ./services/gpg-agent.nix {
};
gpg-agent = import ./services/gpg-agent.nix {
};
languagetool.enable = true;
mailhog.enable = true;
vdirsyncer = {
enable = true;
frequency = "Mon..Thu *-*-* 15,12,8:00";
};
} // (if ownLib.onHikari {} then {
network-manager-applet.enable = true;
} else {
})
languagetool.enable = true;
mailhog.enable = true;
} // (if ownLib.onHikari {} then {
network-manager-applet.enable = true;
} else {
})