From ff9e582e7031db0ae966371ce2358dd359e011bc Mon Sep 17 00:00:00 2001 From: sinavir Date: Mon, 23 Oct 2023 11:35:28 +0200 Subject: [PATCH] feat(linkal): Sync with metis on ens.cal.dgnum.eu --- machines/web01/linkal/default.nix | 8 +++++++- machines/web01/linkal/metis-to-linkal.nix | 24 +++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 machines/web01/linkal/metis-to-linkal.nix diff --git a/machines/web01/linkal/default.nix b/machines/web01/linkal/default.nix index e67fb89..741c13c 100644 --- a/machines/web01/linkal/default.nix +++ b/machines/web01/linkal/default.nix @@ -1,8 +1,10 @@ -_: +{ sources, pkgs, lib, ... }: let host = "cal.dgnum.eu"; + metis2linkal = import ./metis-to-linkal.nix { inherit pkgs lib; }; + calendarGroups = { luj-current = { port = 8444; @@ -19,6 +21,10 @@ let }; }; }; + ens = { + port = 8445; + calendars = metis2linkal sources.metis; + }; }; in { imports = [ ./module.nix ]; diff --git a/machines/web01/linkal/metis-to-linkal.nix b/machines/web01/linkal/metis-to-linkal.nix new file mode 100644 index 0000000..ede478e --- /dev/null +++ b/machines/web01/linkal/metis-to-linkal.nix @@ -0,0 +1,24 @@ +{ lib, pkgs }: +source: +let + #import metis stuff + metisCalendarData = builtins.fromJSON (builtins.readFile (source + /data/calendars.json)); + calendars = metisCalendarData.sources; + inherit (import source { inherit pkgs; }) providers; + + # helper function to map 2-level deep attribute-sets + mapDeepAttrs = mapFct: + lib.concatMapAttrs (name: value: + lib.mapAttrs' (name': value': + mapFct name name' value' + ) value + ); + + + toLinkal = upstream: identifier: + lib.nameValuePair + "https://${providers.${upstream}}/remote.php/dav/public-calendars/${identifier}" + ; + +in + mapDeepAttrs toLinkal calendars