infrastructure/machines/web01/linkal/metis-to-linkal.nix

25 lines
634 B
Nix
Raw Normal View History

{ 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