feat(web01): Deploy multiple linkals on linkal.dgnum.eu

This commit is contained in:
Tom Hubrecht 2023-09-26 18:12:56 +02:00
parent 156310fdce
commit 2857736e6b
4 changed files with 117 additions and 1 deletions

View file

@ -13,6 +13,7 @@ let
# List of services to enable
enabledServices = [
"metis"
"linkal"
"plausible"
# "wordpress"
];

View file

@ -0,0 +1,32 @@
_:
let
host = "linkal.dgnum.eu";
calendarGroups = {
luj-current = {
port = 8443;
calendars = {
"https://cloud.eleves.ens.fr/remote.php/dav/public-calendars/LLWm8qK9iC5YGrrR" = {
name = "Délégation Générale";
short_name = "DG";
};
"https://cloud.eleves.ens.fr/remote.php/dav/public-calendars/fRtjDkjrZyn6fxd8" = {
name = "K-Fêt";
color = "#c63b52";
default_location = "K-Fêt";
};
};
};
};
in {
imports = [ ./module.nix ];
dgn-linkal = {
enable = true;
domain = host;
inherit calendarGroups;
};
}

View file

@ -0,0 +1,71 @@
{ config, lib, pkgs, sources, ... }:
let
inherit (lib) mapAttrs' mkEnableOption mkIf mkOption nameValuePair types;
package = import sources.linkal { inherit pkgs; };
cfg = config.dgn-linkal;
jsonFormat = pkgs.formats.json { };
in {
options.dgn-linkal = {
enable = mkEnableOption "the linkal server.";
package = mkOption {
type = types.package;
default = package.overrideAttrs (_: { buildInputs = [ ]; });
};
domain = mkOption { type = types.str; };
calendarGroups = mkOption {
type = let inherit (types) attrsOf port submodule;
in attrsOf (submodule {
options = {
port = mkOption { type = port; };
calendars = mkOption { inherit (jsonFormat) type; };
};
});
default = { };
};
};
config = mkIf cfg.enable {
systemd.services = mapAttrs' (name:
{ port, calendars }:
nameValuePair "linkal-${name}" {
description = "Linkal - ${name}";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
ExecStart = "${cfg.package}/bin/linkal --port ${
builtins.toString port
} --calendar-file ${
jsonFormat.generate "linkal-${name}.json" { inherit calendars; }
}";
};
}) cfg.calendarGroups;
services.nginx = {
enable = true;
virtualHosts.${cfg.domain} = {
enableACME = true;
forceSSL = true;
locations = mapAttrs' (name:
{ port, ... }:
nameValuePair "^~ /${name}" {
proxyPass = "http://127.0.0.1:${builtins.toString port}/";
# extraConfig = ''
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header Host $host;
# proxy_redirect off;
# '';
}) cfg.calendarGroups;
};
};
};
}

View file

@ -1,5 +1,17 @@
{
"pins": {
"linkal": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "JulienMalka",
"repo": "Linkal"
},
"branch": "main",
"revision": "8744b00eb819f181842f678bed6c1239f8210618",
"url": "https://github.com/JulienMalka/Linkal/archive/8744b00eb819f181842f678bed6c1239f8210618.tar.gz",
"hash": "03nk7x078bcvvv4i9xn29hpv041zxy62z2lfigxwdq1m8cnbwziw"
},
"agenix": {
"type": "GitRelease",
"repository": {
@ -98,4 +110,4 @@
}
},
"version": 3
}
}