feat(linkal): Put calendars of metis in a linkal instance
This commit is contained in:
parent
566b392b21
commit
0ee8760f8d
|
@ -1,6 +1,26 @@
|
|||
_:
|
||||
|
||||
{ lib, pkgs, sources, metisProviders, ...}:
|
||||
let
|
||||
metisConf = pkgs.runCommandLocal "linkal-metis.json" {} ''
|
||||
# jq dark magic
|
||||
cat << EOF > script.jq
|
||||
.sources |
|
||||
${lib.concatStringsSep " |\n"
|
||||
(lib.mapAttrsToList (name: value:
|
||||
".\"${name}\" |= (
|
||||
to_entries |
|
||||
map({(\"https://${value}/remote.php/dav/public-calendars/\" + .key): .value}) |
|
||||
add
|
||||
)"
|
||||
) metisProviders)
|
||||
} |
|
||||
to_entries |
|
||||
map(.value) |
|
||||
add |
|
||||
{ calendars: . }
|
||||
EOF
|
||||
|
||||
${pkgs.jq}/bin/jq -f script.jq > $out < ${sources.metis}/data/calendars.json
|
||||
'';
|
||||
host = "cal.dgnum.eu";
|
||||
|
||||
calendarGroups = {
|
||||
|
@ -19,6 +39,10 @@ let
|
|||
};
|
||||
};
|
||||
};
|
||||
ens = {
|
||||
port = 8445;
|
||||
config = metisConf;
|
||||
};
|
||||
};
|
||||
in {
|
||||
imports = [ ./module.nix ];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{ config, lib, pkgs, sources, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mapAttrs' mkEnableOption mkIf mkOption nameValuePair types;
|
||||
inherit (lib) mapAttrs mapAttrs' mkEnableOption mkIf mkOption nameValuePair types;
|
||||
|
||||
package = import sources.linkal { inherit pkgs; };
|
||||
|
||||
|
@ -20,20 +20,26 @@ in {
|
|||
domain = mkOption { type = types.str; };
|
||||
|
||||
calendarGroups = mkOption {
|
||||
type = let inherit (types) attrsOf port submodule;
|
||||
in attrsOf (submodule {
|
||||
type = let inherit (types) attrsOf port submodule path;
|
||||
in attrsOf (submodule ({ config, ... }: {
|
||||
options = {
|
||||
port = mkOption { type = port; };
|
||||
calendars = mkOption { inherit (jsonFormat) type; };
|
||||
config = mkOption {
|
||||
type = path;
|
||||
default = jsonFormat.generate "linkal-config.json" { inherit (config) calendars; };
|
||||
internal = true;
|
||||
};
|
||||
};
|
||||
});
|
||||
}));
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
systemd.services = mapAttrs' (name:
|
||||
{ port, calendars }:
|
||||
{ port, config, ... }:
|
||||
nameValuePair "linkal-${name}" {
|
||||
description = "Linkal - ${name}";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
@ -42,7 +48,7 @@ in {
|
|||
ExecStart = "${cfg.package}/bin/linkal --port ${
|
||||
builtins.toString port
|
||||
} --calendar-file ${
|
||||
jsonFormat.generate "linkal-${name}.json" { inherit calendars; }
|
||||
config
|
||||
}";
|
||||
};
|
||||
}) cfg.calendarGroups;
|
||||
|
|
|
@ -1,30 +1,23 @@
|
|||
{ lib, pkgs, sources, ... }:
|
||||
{ lib, pkgs, sources, metisProviders, ... }:
|
||||
|
||||
let
|
||||
package = (import sources.metis { inherit pkgs; }).production;
|
||||
|
||||
providers = {
|
||||
klub-reseau = "nuage.beta.rz.ens.wtf";
|
||||
eleves-ens = "cloud.eleves.ens.fr";
|
||||
frama-agenda = "framagenda.org";
|
||||
};
|
||||
|
||||
nginxConf = {
|
||||
enableACME = true;
|
||||
forceSSL = true;
|
||||
root = package;
|
||||
|
||||
locations = lib.mapAttrs' (name: attrs:
|
||||
locations = lib.mapAttrs' (name: value:
|
||||
lib.nameValuePair "/cal/${name}/" {
|
||||
extraConfig = ''
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header X-Forwarded-Server $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_pass https://${
|
||||
providers.${name}
|
||||
}/remote.php/dav/public-calendars/;
|
||||
proxy_pass https://${value}/remote.php/dav/public-calendars/;
|
||||
'';
|
||||
}) providers;
|
||||
}) metisProviders;
|
||||
|
||||
extraConfig = ''
|
||||
rewrite ^/calendrier(.*)$ $1 permanent;
|
||||
|
@ -32,6 +25,11 @@ let
|
|||
};
|
||||
|
||||
in {
|
||||
_module.args.metisProviders = {
|
||||
klub-reseau = "nuage.beta.rz.ens.wtf";
|
||||
eleves-ens = "cloud.eleves.ens.fr";
|
||||
frama-agenda = "framagenda.org";
|
||||
};
|
||||
services.nginx.virtualHosts = {
|
||||
"calendrier.eleves.ens.fr" = nginxConf;
|
||||
"calendrier.dgnum.eu" = nginxConf;
|
||||
|
|
Loading…
Reference in a new issue