summaryrefslogtreecommitdiff
path: root/config/services
diff options
context:
space:
mode:
Diffstat (limited to 'config/services')
-rw-r--r--config/services/dav/create-bday-cal.py159
-rw-r--r--config/services/dav/default.nix30
l---------config/services/dav/web1
-rw-r--r--config/services/default.nix10
-rw-r--r--config/services/git/default.nix23
-rw-r--r--config/services/git/shell-commands/default.nix13
-rw-r--r--config/services/git/shell-commands/repo/.gitignore1
-rw-r--r--config/services/git/shell-commands/repo/default.nix19
-rw-r--r--config/services/git/shell-commands/repo/src/bashly.yml83
-rw-r--r--config/services/git/shell-commands/repo/src/create_command.sh25
-rw-r--r--config/services/git/shell-commands/repo/src/lib/check-git-repository.sh7
-rw-r--r--config/services/git/shell-commands/repo/src/lib/check-realpath.sh9
-rw-r--r--config/services/git/shell-commands/repo/src/lib/colors.sh14
-rw-r--r--config/services/git/shell-commands/repo/src/lib/is-git-dir.sh3
-rw-r--r--config/services/git/shell-commands/repo/src/lib/show-descr.sh3
-rw-r--r--config/services/git/shell-commands/repo/src/lib/show-privacy.sh12
-rw-r--r--config/services/git/shell-commands/repo/src/lib/show-repo-summary.sh8
-rw-r--r--config/services/git/shell-commands/repo/src/lib/show-repo.sh6
-rw-r--r--config/services/git/shell-commands/repo/src/lib/show-size.sh3
-rw-r--r--config/services/git/shell-commands/repo/src/remove_command.sh10
-rw-r--r--config/services/git/shell-commands/repo/src/set_description_command.sh14
-rw-r--r--config/services/git/shell-commands/repo/src/set_privacy_command.sh17
-rw-r--r--config/services/git/shell-commands/repo/src/show_command.sh35
l---------config/services/git/web1
-rw-r--r--config/services/mesh/default.nix48
-rw-r--r--config/services/web/dav/default.nix15
-rw-r--r--config/services/web/default.nix27
-rw-r--r--config/services/web/git/about.html3
-rw-r--r--config/services/web/git/cgit.css943
-rw-r--r--config/services/web/git/default.nix49
-rw-r--r--config/services/web/git/head.html1
-rw-r--r--config/services/web/quentin/default.nix20
-rw-r--r--config/services/web/rss/DeutschLernenDeutscheWelleBridge.php39
-rw-r--r--config/services/web/rss/FipAlbumsBridge.php56
-rw-r--r--config/services/web/rss/MaisonDeLaRadioBridge.php137
-rw-r--r--config/services/web/rss/RandonavigoBridge.php33
-rw-r--r--config/services/web/rss/default.nix45
-rw-r--r--config/services/web/webkeydirectory/default.nix25
-rw-r--r--config/services/web/webkeydirectory/hu/44hqjnz5rw4mrr9d18fmecyskbmwxetwbin0 -> 3578 bytes
39 files changed, 1947 insertions, 0 deletions
diff --git a/config/services/dav/create-bday-cal.py b/config/services/dav/create-bday-cal.py
new file mode 100644
index 0000000..32fade9
--- /dev/null
+++ b/config/services/dav/create-bday-cal.py
@@ -0,0 +1,159 @@
+# https://github.com/iBigQ/radicale-birthday-calendar
+
+import fileinput
+import json
+import os
+import random
+import uuid
+from collections import defaultdict
+from datetime import datetime, timedelta
+from typing import Iterator, Any
+
+import dateutil.rrule as rrule
+import vobject
+
+BIRTHDAY_CALENDAR_COLOR = None
+BIRTHDAY_REMINDER_AT_HOUR = True
+
+
+def parse_date(date_str):
+ for date_fmt in ("%Y-%m-%d", "%Y%m%d", "--%m%d"):
+ try:
+ return datetime.strptime(date_str, date_fmt)
+ except ValueError:
+ pass
+ raise ValueError(f"could not parse date {date_str}")
+
+
+def get_changed_files() -> dict[str, list[str]]:
+ user_modifications = defaultdict(list)
+ for changed_file in fileinput.input():
+ changed_file = changed_file.rstrip("\n")
+ if (
+ not changed_file
+ or "/.Radicale.cache/" in changed_file
+ or not changed_file.count("/") >= 3
+ ):
+ continue
+ root, user, collection, file = changed_file.split("/", maxsplit=3)
+ user_modifications[f"{root}/{user}"].append(f"{collection}/{file}")
+ return user_modifications
+
+
+def get_user_collections(user: str) -> dict[str, str]:
+ user_collections = {}
+ dirpath, dirnames, filenames = next(os.walk(user), ([], [], []))
+ for collection in dirnames:
+ try:
+ with open(f"{user}/{collection}/.Radicale.props", "r") as fp:
+ tag = json.load(fp)["tag"]
+ except (FileNotFoundError, json.JSONDecodeError, KeyError):
+ continue
+ else:
+ user_collections[collection] = tag
+ return user_collections
+
+
+def get_entries(collection: str) -> Iterator[tuple[str, Any]]:
+ dirpath, dirnames, filenames = next(os.walk(collection), ([], [], []))
+ for filename in filenames:
+ if filename.startswith(".Radicale"):
+ continue
+ with open(f"{dirpath}/{filename}", "r") as fp:
+ for entry in vobject.readComponents(fp.read()):
+ yield f"{collection}/{filename}", entry
+
+
+def get_birthday_calendar(user: str) -> Iterator[tuple[str, Any]]:
+ collection = f"{user}/birthdays"
+ if not os.path.exists(collection):
+ os.makedirs(collection, exist_ok=True)
+ fn = f"{collection}/.Radicale.props"
+ if not os.path.exists(fn):
+ with open(fn, "w") as fp:
+ # (Optional) Get calendar color from environment
+ if BIRTHDAY_CALENDAR_COLOR:
+ # If color was set, strip '#' for consistency
+ color = BIRTHDAY_CALENDAR_COLOR.strip("#")
+ else:
+ # Or alternatively choose something at random
+ color = "".join(random.choices("0123456abcdef", k=6))
+
+ data = {
+ "C:supported-calendar-component-set": "VEVENT",
+ "D:displayname": "Birthdays",
+ "C:calendar-description": "[AUTO GENERATED] "
+ + "Birthdays from all addressbooks",
+ "ICAL:calendar-color": f"#{color}",
+ "tag": "VCALENDAR",
+ }
+ json.dump(data, fp, indent=None)
+ yield from get_entries(collection)
+
+
+def create_birthday(user: str, contact):
+ calendar = vobject.iCalendar()
+
+ # Basic event properties
+ event = calendar.add("vevent")
+ event.add("summary").value = contact.fn.value
+ event.add("dtstart").value = parse_date(contact.bday.value).date()
+ event.add("dtend").value = event.dtstart.value + timedelta(days=1)
+ event.add("uid").value = contact.uid.value
+
+ # (Optional) Set reminder
+ if BIRTHDAY_REMINDER_AT_HOUR:
+ alarm = event.add("valarm")
+ alarm.add("action").value = "DISPLAY"
+ alarm.add("description").value = "Reminder"
+ alarm.add("trigger").value = timedelta(hours=0)
+ alarm.add("uid").value = str(uuid.uuid4())
+
+ # Repeat yearly
+ newrule = rrule.rruleset()
+ newrule.rrule(rrule.rrule(rrule.YEARLY, dtstart=event.dtstart.value))
+ event.rruleset = newrule
+
+ # Write to disk
+ collection = f"{user}/birthdays"
+ with open(f"{collection}/{contact.uid.value}.ics", "w") as fp:
+ fp.write(calendar.serialize())
+
+
+def main():
+ user_to_changes = get_changed_files()
+ user_to_collections = {
+ user: get_user_collections(user) for user in user_to_changes
+ }
+
+ for user, changed_files in user_to_changes.items():
+ contacts = {
+ contact.uid.value: contact
+ for collection, tag in user_to_collections[user].items()
+ if tag == "VADDRESSBOOK"
+ for _, contact in get_entries(f"{user}/{collection}")
+ if hasattr(contact, "bday")
+ }
+ birthday_entries = {
+ user_bday.vevent.uid.value: (fn, user_bday)
+ for fn, user_bday in get_birthday_calendar(user)
+ }
+
+ # Check existing birthday entries
+ for bday_uid, (bday_file, bday_event) in birthday_entries.items():
+ # Delete old ones
+ if bday_uid not in contacts:
+ os.unlink(bday_file)
+ # Keep unchanged
+ elif not any(
+ bday_uid in changed_file for changed_file in changed_files
+ ):
+ del contacts[bday_uid]
+
+ # Write new and modified contacts
+ for contact in contacts.values():
+ create_birthday(user, contact)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/config/services/dav/default.nix b/config/services/dav/default.nix
new file mode 100644
index 0000000..2157ad0
--- /dev/null
+++ b/config/services/dav/default.nix
@@ -0,0 +1,30 @@
+{ config, pkgs, ... }:
+
+{
+ services.radicale = {
+ enable = true;
+ settings = {
+ auth = {
+ type = "htpasswd";
+ # generate with
+ # nix shell nixpkgs#apacheHttpd --command htpasswd -cB .htpasswd username
+ htpasswd_filename = "/etc/radicale/.htpasswd";
+ htpasswd_encryption = "bcrypt";
+ };
+ storage = {
+ filesystem_folder = "/srv/dav/collections";
+ hook = "${
+ pkgs.writers.writePython3Bin "create-bday-cal" {
+ libraries = with pkgs.python3Packages; [
+ python-dateutil
+ vobject
+ ];
+ } (builtins.readFile ./create-bday-cal.py)
+ }/bin/create-bday-cal";
+ };
+ web.type = "none";
+ };
+ };
+
+ systemd.services.radicale.personal.monitor = true;
+}
diff --git a/config/services/dav/web b/config/services/dav/web
new file mode 120000
index 0000000..7698db0
--- /dev/null
+++ b/config/services/dav/web
@@ -0,0 +1 @@
+../web/dav/ \ No newline at end of file
diff --git a/config/services/default.nix b/config/services/default.nix
new file mode 100644
index 0000000..0cdc85d
--- /dev/null
+++ b/config/services/default.nix
@@ -0,0 +1,10 @@
+{ ... }:
+
+{
+ imports = [
+ ./dav
+ ./git
+ ./mesh
+ ./web
+ ];
+}
diff --git a/config/services/git/default.nix b/config/services/git/default.nix
new file mode 100644
index 0000000..1ebc5e6
--- /dev/null
+++ b/config/services/git/default.nix
@@ -0,0 +1,23 @@
+{ config, pkgs, ... }:
+
+{
+ imports = [
+ ./shell-commands
+ ];
+
+ users.users.git = {
+ isSystemUser = true;
+ group = "git";
+ createHome = true;
+ homeMode = "750";
+ home = "/srv/git";
+ shell = "${pkgs.git}/bin/git-shell";
+ openssh.authorizedKeys.keys = with config.personal.lib.publicKeys.ssh; [
+ latitude-7490
+ precision-3571
+ dragonfly-g4
+ ];
+ };
+
+ users.groups.git = { };
+}
diff --git a/config/services/git/shell-commands/default.nix b/config/services/git/shell-commands/default.nix
new file mode 100644
index 0000000..c27bf9c
--- /dev/null
+++ b/config/services/git/shell-commands/default.nix
@@ -0,0 +1,13 @@
+{ lib, pkgs, ... }:
+
+let
+ repo = import ./repo { inherit lib pkgs; };
+ gitShellCommands = "/srv/git/git-shell-commands";
+in
+{
+ system.activationScripts.buildGitShell.text = ''
+ install --mode u=rX,g=,o= --owner git --group git --directory ${gitShellCommands}
+ rm -rf ${gitShellCommands}/*
+ ln -s ${repo} ${gitShellCommands}/repo
+ '';
+}
diff --git a/config/services/git/shell-commands/repo/.gitignore b/config/services/git/shell-commands/repo/.gitignore
new file mode 100644
index 0000000..ffdcec4
--- /dev/null
+++ b/config/services/git/shell-commands/repo/.gitignore
@@ -0,0 +1 @@
+repo \ No newline at end of file
diff --git a/config/services/git/shell-commands/repo/default.nix b/config/services/git/shell-commands/repo/default.nix
new file mode 100644
index 0000000..bbccbfd
--- /dev/null
+++ b/config/services/git/shell-commands/repo/default.nix
@@ -0,0 +1,19 @@
+{ lib, pkgs }:
+
+pkgs.stdenvNoCC.mkDerivation {
+ name = "repo";
+ src = lib.fileset.toSource {
+ root = ./src;
+ fileset = ./src;
+ };
+ buildInputs = [ pkgs.bashly ];
+ unpackPhase = ''
+ ln --symbolic --no-target-directory "$src" src
+ '';
+ buildPhase = ''
+ bashly generate
+ '';
+ installPhase = ''
+ install ./repo "$out"
+ '';
+}
diff --git a/config/services/git/shell-commands/repo/src/bashly.yml b/config/services/git/shell-commands/repo/src/bashly.yml
new file mode 100644
index 0000000..6a216ae
--- /dev/null
+++ b/config/services/git/shell-commands/repo/src/bashly.yml
@@ -0,0 +1,83 @@
+name: repo
+help: show and configure repositories
+
+commands:
+- name: show
+ help: show repositories
+ default: true
+
+ args:
+ - name: path
+ required: false
+ help: path in which to list repositories
+
+ flags:
+ - long: --verbose
+ short: -v
+ help: show repository description
+ - long: --tree
+ short: -t
+ help: show intermediate directories
+
+ examples:
+ - "repo show # list all repositories"
+ - "repo show --verbose # list repositories in details"
+ - "repo show about-me # list repositories in the about-me/ folder"
+ - "repo show about-me/cv # show the about-me/cv repository"
+ - "repo show --tree # list all repositories as well as intermediate directories"
+
+- name: set
+ help: configure repository
+
+ commands:
+ - name: description
+ alias: descr
+ help: set repository description
+
+ args:
+ - name: repo
+ required: true
+ help: repository path
+
+ examples:
+ - repo set descr about-me/cv
+
+ - name: privacy
+ alias: prv
+ help: recursively set repository visibility
+
+ args:
+ - name: path
+ required: true
+ help: repository path
+ - name: visibility
+ required: true
+ help: new repository visibility
+ allowed: [public, private]
+
+ examples:
+ - "repo set prv public about-me/cv # change visibility of a single repository"
+ - "repo set prv public about-me # change visibility of all repositories in a tree"
+
+- name: create
+ help: create bare repositories
+
+ args:
+ - name: repo
+ required: true
+ help: repository path
+
+ examples:
+ - repo create path/to/repo
+
+- name: remove
+ alias: rm
+ help: remove repository or empty directory
+
+ args:
+ - name: path
+ required: true
+ help: repository path
+
+ examples:
+ - repo rm path/to/repo
diff --git a/config/services/git/shell-commands/repo/src/create_command.sh b/config/services/git/shell-commands/repo/src/create_command.sh
new file mode 100644
index 0000000..ab8bf3f
--- /dev/null
+++ b/config/services/git/shell-commands/repo/src/create_command.sh
@@ -0,0 +1,25 @@
+repo=$(realpath --canonicalize-missing /srv/git/"${args[repo]}")
+
+if [[ ! "$repo" == /srv/git/* ]]
+then
+ red "Forbidden path."
+ exit 2
+fi
+
+subpath=/srv/git
+IFS='/' read -ra dirs <<< "${repo#/srv/git/}"
+for dir in "${dirs[@]}"; do
+ subpath="$subpath/$dir"
+ if [[ ! -d "$subpath" ]]
+ then
+ break
+ fi
+done
+
+mkdir --parents "$repo"
+chmod u=rwX,g=,o= --recursive "$subpath"
+git init --bare "$repo"
+
+args[path]="$repo"
+args[--tree]=1
+repo_show_command
diff --git a/config/services/git/shell-commands/repo/src/lib/check-git-repository.sh b/config/services/git/shell-commands/repo/src/lib/check-git-repository.sh
new file mode 100644
index 0000000..c974890
--- /dev/null
+++ b/config/services/git/shell-commands/repo/src/lib/check-git-repository.sh
@@ -0,0 +1,7 @@
+check-git-repository() {
+ if [[ ! $(is-git-dir "$1") ]]
+ then
+ red "Not a git repository."
+ exit 2
+ fi
+}
diff --git a/config/services/git/shell-commands/repo/src/lib/check-realpath.sh b/config/services/git/shell-commands/repo/src/lib/check-realpath.sh
new file mode 100644
index 0000000..c344bd2
--- /dev/null
+++ b/config/services/git/shell-commands/repo/src/lib/check-realpath.sh
@@ -0,0 +1,9 @@
+check-realpath() {
+ local path="$1"
+ if [[ ! -e "$path" ]] \
+ || [[ ! "$path" == /srv/git/* ]]
+ then
+ red "Forbidden path."
+ exit 2
+ fi
+}
diff --git a/config/services/git/shell-commands/repo/src/lib/colors.sh b/config/services/git/shell-commands/repo/src/lib/colors.sh
new file mode 100644
index 0000000..a78911d
--- /dev/null
+++ b/config/services/git/shell-commands/repo/src/lib/colors.sh
@@ -0,0 +1,14 @@
+print_in_color() {
+ local color="$1"
+ shift
+ if [[ "${NO_COLOR:-}" == "" ]]; then
+ printf "$color%b\e[0m\n" "$*"
+ else
+ printf "%b\n" "$*"
+ fi
+}
+
+red() { print_in_color "\e[31m" "$*"; }
+green() { print_in_color "\e[32m" "$*"; }
+blue() { print_in_color "\e[34m" "$*"; }
+bold() { print_in_color "\e[1m" "$*"; }
diff --git a/config/services/git/shell-commands/repo/src/lib/is-git-dir.sh b/config/services/git/shell-commands/repo/src/lib/is-git-dir.sh
new file mode 100644
index 0000000..d94f2ba
--- /dev/null
+++ b/config/services/git/shell-commands/repo/src/lib/is-git-dir.sh
@@ -0,0 +1,3 @@
+is-git-dir() {
+ git rev-parse --resolve-git-dir "$1" 2>/dev/null
+}
diff --git a/config/services/git/shell-commands/repo/src/lib/show-descr.sh b/config/services/git/shell-commands/repo/src/lib/show-descr.sh
new file mode 100644
index 0000000..edf6d34
--- /dev/null
+++ b/config/services/git/shell-commands/repo/src/lib/show-descr.sh
@@ -0,0 +1,3 @@
+show-descr() {
+ echo "| $(cat "$1"/description)"
+}
diff --git a/config/services/git/shell-commands/repo/src/lib/show-privacy.sh b/config/services/git/shell-commands/repo/src/lib/show-privacy.sh
new file mode 100644
index 0000000..11df8d1
--- /dev/null
+++ b/config/services/git/shell-commands/repo/src/lib/show-privacy.sh
@@ -0,0 +1,12 @@
+show-privacy() {
+ local mode=$(( $(stat -c %a "$1")/10 %10 ))
+ if [[ $mode == 0 ]]
+ then
+ red private
+ elif [[ $mode == 5 ]]
+ then
+ green public
+ else
+ blue unknown
+ fi
+}
diff --git a/config/services/git/shell-commands/repo/src/lib/show-repo-summary.sh b/config/services/git/shell-commands/repo/src/lib/show-repo-summary.sh
new file mode 100644
index 0000000..7c0bf63
--- /dev/null
+++ b/config/services/git/shell-commands/repo/src/lib/show-repo-summary.sh
@@ -0,0 +1,8 @@
+show-repo-summary() {
+ local repo="$1"
+ local name="${repo#/srv/git/}"
+ local privacy=$(show-privacy "$repo")
+ local size=$(show-size "$repo")
+ printf "%-16s %4s " "$privacy" "$size"
+ bold "$name"
+}
diff --git a/config/services/git/shell-commands/repo/src/lib/show-repo.sh b/config/services/git/shell-commands/repo/src/lib/show-repo.sh
new file mode 100644
index 0000000..d125341
--- /dev/null
+++ b/config/services/git/shell-commands/repo/src/lib/show-repo.sh
@@ -0,0 +1,6 @@
+show-repo() {
+ local repo="$1"
+ show-repo-summary "$repo"
+ printf "%13s" ""
+ show-descr "$repo"
+}
diff --git a/config/services/git/shell-commands/repo/src/lib/show-size.sh b/config/services/git/shell-commands/repo/src/lib/show-size.sh
new file mode 100644
index 0000000..739f61d
--- /dev/null
+++ b/config/services/git/shell-commands/repo/src/lib/show-size.sh
@@ -0,0 +1,3 @@
+show-size() {
+ du --human-readable --summarize "$1" | cut --field 1
+}
diff --git a/config/services/git/shell-commands/repo/src/remove_command.sh b/config/services/git/shell-commands/repo/src/remove_command.sh
new file mode 100644
index 0000000..b45406f
--- /dev/null
+++ b/config/services/git/shell-commands/repo/src/remove_command.sh
@@ -0,0 +1,10 @@
+path=$(realpath "${args[path]}")
+
+check-realpath "$path"
+
+if [[ $(is-git-dir "$path") ]]
+then
+ rm --recursive "$path"
+else
+ rm --dir "$path"
+fi
diff --git a/config/services/git/shell-commands/repo/src/set_description_command.sh b/config/services/git/shell-commands/repo/src/set_description_command.sh
new file mode 100644
index 0000000..b6b40f0
--- /dev/null
+++ b/config/services/git/shell-commands/repo/src/set_description_command.sh
@@ -0,0 +1,14 @@
+repo=$(realpath "${args[repo]}")
+
+echo "$repo"
+check-realpath "$repo"
+check-git-repository "$repo"
+echo "Old description:"
+show-descr "$repo"
+echo "New description:"
+echo -n "| "
+read descr
+echo
+echo "$descr" > "$repo"/description
+show-repo "$repo"
+
diff --git a/config/services/git/shell-commands/repo/src/set_privacy_command.sh b/config/services/git/shell-commands/repo/src/set_privacy_command.sh
new file mode 100644
index 0000000..db033e6
--- /dev/null
+++ b/config/services/git/shell-commands/repo/src/set_privacy_command.sh
@@ -0,0 +1,17 @@
+path=$(realpath "${args[path]}")
+
+check-realpath "$path"
+
+case "${args[visibility]}" in
+ public)
+ mode="rX"
+ ;;
+ private)
+ mode=""
+ ;;
+esac
+
+chmod g="$mode" --recursive "$path"
+args[--tree]=1
+args[path]="$path"
+repo_show_command
diff --git a/config/services/git/shell-commands/repo/src/show_command.sh b/config/services/git/shell-commands/repo/src/show_command.sh
new file mode 100644
index 0000000..77bb92f
--- /dev/null
+++ b/config/services/git/shell-commands/repo/src/show_command.sh
@@ -0,0 +1,35 @@
+if [[ -z "${args[path]}" ]]
+then
+ path=/srv/git/
+else
+ path=$(realpath "${args[path]}")
+ check-realpath "$path"
+fi
+
+if [[ $(is-git-dir "$path") ]]
+then
+ args[--verbose]=1
+fi
+
+dirs=$(find "$path" -type f -name HEAD | while read -r head; do
+ dir="${head%/*}"
+ if [[ "${args[--tree]}" ]]
+ then
+ while [[ "$dir" != "/srv/git" && -n "$dir" ]]; do
+ echo "$dir/"
+ dir="${dir%/*}"
+ done
+ else
+ echo "$dir/"
+ fi
+ done | sort -u)
+
+for dir in $dirs
+do
+ if [[ "${args[--verbose]}" ]] && [[ $(is-git-dir "$dir") ]]
+ then
+ show-repo "$dir"
+ else
+ show-repo-summary "$dir"
+ fi
+done
diff --git a/config/services/git/web b/config/services/git/web
new file mode 120000
index 0000000..d590dc7
--- /dev/null
+++ b/config/services/git/web
@@ -0,0 +1 @@
+../web/git/ \ No newline at end of file
diff --git a/config/services/mesh/default.nix b/config/services/mesh/default.nix
new file mode 100644
index 0000000..0d596cc
--- /dev/null
+++ b/config/services/mesh/default.nix
@@ -0,0 +1,48 @@
+{
+ config,
+ lib,
+ ...
+}:
+let
+ cfg = config.services.headscale;
+ url = "mesh.${config.networking.domain}";
+in
+{
+ networking.firewall.allowedUDPPorts = [ 3478 ];
+
+ services.headscale = {
+ enable = true;
+ port = 8001;
+ settings = {
+ server_url = "https://${url}:443";
+ derps = {
+ server = {
+ enabled = true;
+ stun_listen_addr = "0.0.0.0:3478";
+ };
+ urls = [ ];
+ };
+ dns = {
+ base_domain = "aristote.mesh";
+ override_local_dns = false;
+ };
+ };
+ };
+
+ systemd.services.headscale.personal.monitor = true;
+
+ services.nginx.virtualHosts.mesh = lib.mkIf cfg.enable {
+ serverName = "${url}";
+ forceSSL = true;
+ enableACME = true;
+ locations."/" = {
+ proxyPass = "http://${cfg.address}:${toString cfg.port}";
+ proxyWebsockets = true;
+ extraConfig = ''
+ proxy_redirect http:// https://;
+ proxy_buffering off;
+ add_header Strict-Transport-Security "max-age=15552000; includeSubDomains" always;
+ '';
+ };
+ };
+}
diff --git a/config/services/web/dav/default.nix b/config/services/web/dav/default.nix
new file mode 100644
index 0000000..06b9639
--- /dev/null
+++ b/config/services/web/dav/default.nix
@@ -0,0 +1,15 @@
+{ config, ... }:
+
+{
+ services.nginx.virtualHosts.dav = {
+ serverName = "dav.${config.networking.domain}";
+ enableACME = true;
+ forceSSL = true;
+ locations."/" = {
+ proxyPass = "http://localhost:5232/"; # default radicale host
+ extraConfig = ''
+ proxy_redirect default;
+ '';
+ };
+ };
+}
diff --git a/config/services/web/default.nix b/config/services/web/default.nix
new file mode 100644
index 0000000..cb7038f
--- /dev/null
+++ b/config/services/web/default.nix
@@ -0,0 +1,27 @@
+{ ... }:
+
+{
+ imports = [
+ ./dav
+ ./git
+ ./quentin
+ ./rss
+ ./webkeydirectory
+ ];
+
+ security.acme = {
+ acceptTerms = true;
+ defaults.email = "quentin@aristote.fr";
+ };
+
+ services.nginx = {
+ enable = true;
+ # return 444 when trying to connect to some unknown virtual host
+ virtualHosts."_" = {
+ default = true;
+ extraConfig = ''
+ return 444;
+ '';
+ };
+ };
+}
diff --git a/config/services/web/git/about.html b/config/services/web/git/about.html
new file mode 100644
index 0000000..32f909c
--- /dev/null
+++ b/config/services/web/git/about.html
@@ -0,0 +1,3 @@
+<p>
+ This website lists <a href="https://quentin.aristote.fr/">my</a> personal Git repositories. See also the Git repositories for <a href="https://git.eleves.ens.fr/qaristote">my student projects</a> and for <a href="https://gitlab.math.univ-paris-diderot.fr/aristote">my professional projects</a>.
+</p>
diff --git a/config/services/web/git/cgit.css b/config/services/web/git/cgit.css
new file mode 100644
index 0000000..633fead
--- /dev/null
+++ b/config/services/web/git/cgit.css
@@ -0,0 +1,943 @@
+/* inspired by https://github.com/MatejaMaric/responsive-cgit-css */
+
+div#cgit {
+ padding: 0em;
+ margin: 0em;
+ font-family: sans-serif;
+ font-size: 10pt;
+ color: #333;
+ background: white;
+ padding: 4px;
+}
+
+div#cgit a {
+ color: blue;
+ text-decoration: none;
+}
+
+div#cgit a:hover {
+ text-decoration: underline;
+}
+
+div#cgit table {
+ border-collapse: collapse;
+}
+
+div#cgit table#header {
+ width: 100%;
+ margin-bottom: 1em;
+}
+
+div#cgit table#header td.logo {
+ width: 96px;
+ vertical-align: top;
+}
+
+div#cgit table#header td.main {
+ font-size: 250%;
+ padding-left: 10px;
+ white-space: nowrap;
+}
+
+div#cgit table#header td.main a {
+ color: #000;
+}
+
+div#cgit table#header td.form {
+ text-align: right;
+ vertical-align: bottom;
+ padding-right: 1em;
+ padding-bottom: 2px;
+ white-space: nowrap;
+}
+
+div#cgit table#header td.form form,
+div#cgit table#header td.form input,
+div#cgit table#header td.form select {
+ font-size: 90%;
+}
+
+div#cgit table#header td.sub {
+ color: #777;
+ border-top: solid 1px #ccc;
+ padding-left: 10px;
+}
+
+div#cgit table.tabs {
+ border-bottom: solid 3px #ccc;
+ border-collapse: collapse;
+ margin-top: 2em;
+ margin-bottom: 0px;
+ width: 100%;
+}
+
+div#cgit table.tabs td {
+ padding: 0px 1em;
+ vertical-align: bottom;
+}
+
+div#cgit table.tabs td a {
+ padding: 2px 0.75em;
+ color: #777;
+ font-size: 110%;
+}
+
+div#cgit table.tabs td a.active {
+ color: #000;
+ background-color: #ccc;
+}
+
+div#cgit table.tabs a[href^="http://"]:after, div#cgit table.tabs a[href^="https://"]:after {
+ content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAQAAAAnOwc2AAAAAmJLR0QA/4ePzL8AAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfgAhcJDQY+gm2TAAAAHWlUWHRDb21tZW50AAAAAABDcmVhdGVkIHdpdGggR0lNUGQuZQcAAABbSURBVAhbY2BABs4MU4CwhYHBh2Erww4wrGFQZHjI8B8IgUIscJWyDHcggltQhI4zGDCcRwhChPggHIggP1QoAVmQkSETrGoHsiAEsACtBYN0oDAMbgU6EBcAAL2eHUt4XUU4AAAAAElFTkSuQmCC);
+ opacity: 0.5;
+ margin: 0 0 0 5px;
+}
+
+div#cgit table.tabs td.form {
+ text-align: right;
+}
+
+div#cgit table.tabs td.form form {
+ padding-bottom: 2px;
+ font-size: 90%;
+ white-space: nowrap;
+}
+
+div#cgit table.tabs td.form input,
+div#cgit table.tabs td.form select {
+ font-size: 90%;
+}
+
+div#cgit div.path {
+ margin: 0px;
+ padding: 5px 2em 2px 2em;
+ color: #000;
+ background-color: #eee;
+}
+
+div#cgit div.content {
+ margin: 0px;
+ padding: 2em;
+ border-bottom: solid 3px #ccc;
+}
+
+
+div#cgit table.list {
+ width: 100%;
+ border: none;
+ border-collapse: collapse;
+}
+
+div#cgit table.list tr {
+ background: white;
+}
+
+div#cgit table.list tr.logheader {
+ background: #eee;
+}
+
+div#cgit table.list tr:nth-child(even) {
+ background: #f7f7f7;
+}
+
+div#cgit table.list tr:nth-child(odd) {
+ background: white;
+}
+
+div#cgit table.list tr:hover {
+ background: #eee;
+}
+
+div#cgit table.list tr.nohover {
+ background: white;
+}
+
+div#cgit table.list tr.nohover:hover {
+ background: white;
+}
+
+div#cgit table.list tr.nohover-highlight:hover:nth-child(even) {
+ background: #f7f7f7;
+}
+
+div#cgit table.list tr.nohover-highlight:hover:nth-child(odd) {
+ background: white;
+}
+
+div#cgit table.list th {
+ font-weight: bold;
+ /* color: #888;
+ border-top: dashed 1px #888;
+ border-bottom: dashed 1px #888;
+ */
+ padding: 0.1em 0.5em 0.05em 0.5em;
+ vertical-align: baseline;
+}
+
+div#cgit table.list td {
+ border: none;
+ padding: 0.1em 0.5em 0.1em 0.5em;
+}
+
+div#cgit table.list td.commitgraph {
+ font-family: monospace;
+ white-space: pre;
+}
+
+div#cgit table.list td.commitgraph .column1 {
+ color: #a00;
+}
+
+div#cgit table.list td.commitgraph .column2 {
+ color: #0a0;
+}
+
+div#cgit table.list td.commitgraph .column3 {
+ color: #aa0;
+}
+
+div#cgit table.list td.commitgraph .column4 {
+ color: #00a;
+}
+
+div#cgit table.list td.commitgraph .column5 {
+ color: #a0a;
+}
+
+div#cgit table.list td.commitgraph .column6 {
+ color: #0aa;
+}
+
+div#cgit table.list td.logsubject {
+ font-family: monospace;
+ font-weight: bold;
+}
+
+div#cgit table.list td.logmsg {
+ font-family: monospace;
+ white-space: pre;
+ padding: 0 0.5em;
+}
+
+div#cgit table.list td a {
+ color: black;
+}
+
+div#cgit table.list td a.ls-dir {
+ font-weight: bold;
+ color: #00f;
+}
+
+div#cgit table.list td a:hover {
+ color: #00f;
+}
+
+div#cgit img {
+ border: none;
+}
+
+div#cgit input#switch-btn {
+ margin: 2px 0px 0px 0px;
+}
+
+div#cgit td#sidebar input.txt {
+ width: 100%;
+ margin: 2px 0px 0px 0px;
+}
+
+div#cgit table#grid {
+ margin: 0px;
+}
+
+div#cgit td#content {
+ vertical-align: top;
+ padding: 1em 2em 1em 1em;
+ border: none;
+}
+
+div#cgit div#summary {
+ vertical-align: top;
+ margin-bottom: 1em;
+}
+
+div#cgit table#downloads {
+ float: right;
+ border-collapse: collapse;
+ border: solid 1px #777;
+ margin-left: 0.5em;
+ margin-bottom: 0.5em;
+}
+
+div#cgit table#downloads th {
+ background-color: #ccc;
+}
+
+div#cgit div#blob {
+ border: solid 1px black;
+}
+
+div#cgit div.error {
+ color: red;
+ font-weight: bold;
+ margin: 1em 2em;
+}
+
+div#cgit a.ls-blob, div#cgit a.ls-dir, div#cgit .ls-mod {
+ font-family: monospace;
+}
+
+div#cgit td.ls-size {
+ text-align: right;
+ font-family: monospace;
+ width: 10em;
+}
+
+div#cgit td.ls-mode {
+ font-family: monospace;
+ width: 10em;
+}
+
+div#cgit table.blob {
+ margin-top: 0.5em;
+ border-top: solid 1px black;
+}
+
+div#cgit table.blob td.hashes,
+div#cgit table.blob td.lines {
+ margin: 0; padding: 0 0 0 0.5em;
+ vertical-align: top;
+ color: black;
+}
+
+div#cgit table.blob td.linenumbers {
+ margin: 0; padding: 0 0.5em 0 0.5em;
+ vertical-align: top;
+ text-align: right;
+ border-right: 1px solid gray;
+}
+
+div#cgit table.blob pre {
+ padding: 0; margin: 0;
+}
+
+div#cgit table.blob td.linenumbers a,
+div#cgit table.ssdiff td.lineno a {
+ color: gray;
+ text-align: right;
+ text-decoration: none;
+}
+
+div#cgit table.blob td.linenumbers a:hover,
+div#cgit table.ssdiff td.lineno a:hover {
+ color: black;
+}
+
+div#cgit table.blame td.hashes,
+div#cgit table.blame td.lines,
+div#cgit table.blame td.linenumbers {
+ padding: 0;
+}
+
+div#cgit table.blame td.hashes div.alt,
+div#cgit table.blame td.lines div.alt {
+ padding: 0 0.5em 0 0.5em;
+}
+
+div#cgit table.blame td.linenumbers div.alt {
+ padding: 0 0.5em 0 0;
+}
+
+div#cgit table.blame div.alt:nth-child(even) {
+ background: #eee;
+}
+
+div#cgit table.blame div.alt:nth-child(odd) {
+ background: white;
+}
+
+div#cgit table.blame td.lines > div {
+ position: relative;
+}
+
+div#cgit table.blame td.lines > div > pre {
+ padding: 0 0 0 0.5em;
+ position: absolute;
+ top: 0;
+}
+
+div#cgit table.bin-blob {
+ margin-top: 0.5em;
+ border: solid 1px black;
+}
+
+div#cgit table.bin-blob th {
+ font-family: monospace;
+ white-space: pre;
+ border: solid 1px #777;
+ padding: 0.5em 1em;
+}
+
+div#cgit table.bin-blob td {
+ font-family: monospace;
+ white-space: pre;
+ border-left: solid 1px #777;
+ padding: 0em 1em;
+}
+
+div#cgit table.nowrap td {
+ white-space: nowrap;
+}
+
+div#cgit table.commit-info {
+ border-collapse: collapse;
+ margin-top: 1.5em;
+}
+
+div#cgit div.cgit-panel {
+ float: right;
+ margin-top: 1.5em;
+}
+
+div#cgit div.cgit-panel table {
+ border-collapse: collapse;
+ border: solid 1px #aaa;
+ background-color: #eee;
+}
+
+div#cgit div.cgit-panel th {
+ text-align: center;
+}
+
+div#cgit div.cgit-panel td {
+ padding: 0.25em 0.5em;
+}
+
+div#cgit div.cgit-panel td.label {
+ padding-right: 0.5em;
+}
+
+div#cgit div.cgit-panel td.ctrl {
+ padding-left: 0.5em;
+}
+
+div#cgit table.commit-info th {
+ text-align: left;
+ font-weight: normal;
+ padding: 0.1em 1em 0.1em 0.1em;
+ vertical-align: top;
+}
+
+div#cgit table.commit-info td {
+ font-weight: normal;
+ padding: 0.1em 1em 0.1em 0.1em;
+}
+
+div#cgit div.commit-subject {
+ font-weight: bold;
+ font-size: 125%;
+ margin: 1.5em 0em 0.5em 0em;
+ padding: 0em;
+}
+
+div#cgit div.commit-msg {
+ white-space: pre;
+ font-family: monospace;
+}
+
+div#cgit div.notes-header {
+ font-weight: bold;
+ padding-top: 1.5em;
+}
+
+div#cgit div.notes {
+ white-space: pre;
+ font-family: monospace;
+ border: solid 1px #ee9;
+ background-color: #ffd;
+ padding: 0.3em 2em 0.3em 1em;
+ float: left;
+}
+
+div#cgit div.notes-footer {
+ clear: left;
+}
+
+div#cgit div.diffstat-header {
+ font-weight: bold;
+ padding-top: 1.5em;
+}
+
+div#cgit table.diffstat {
+ border-collapse: collapse;
+ border: solid 1px #aaa;
+ background-color: #eee;
+}
+
+div#cgit table.diffstat th {
+ font-weight: normal;
+ text-align: left;
+ text-decoration: underline;
+ padding: 0.1em 1em 0.1em 0.1em;
+ font-size: 100%;
+}
+
+div#cgit table.diffstat td {
+ padding: 0.2em 0.2em 0.1em 0.1em;
+ font-size: 100%;
+ border: none;
+}
+
+div#cgit table.diffstat td.mode {
+ white-space: nowrap;
+}
+
+div#cgit table.diffstat td span.modechange {
+ padding-left: 1em;
+ color: red;
+}
+
+div#cgit table.diffstat td.add a {
+ color: green;
+}
+
+div#cgit table.diffstat td.del a {
+ color: red;
+}
+
+div#cgit table.diffstat td.upd a {
+ color: blue;
+}
+
+div#cgit table.diffstat td.graph {
+ width: 500px;
+ vertical-align: middle;
+}
+
+div#cgit table.diffstat td.graph table {
+ border: none;
+}
+
+div#cgit table.diffstat td.graph td {
+ padding: 0px;
+ border: 0px;
+ height: 7pt;
+}
+
+div#cgit table.diffstat td.graph td.add {
+ background-color: #5c5;
+}
+
+div#cgit table.diffstat td.graph td.rem {
+ background-color: #c55;
+}
+
+div#cgit div.diffstat-summary {
+ color: #888;
+ padding-top: 0.5em;
+}
+
+div#cgit table.diff {
+ width: 100%;
+}
+
+div#cgit table.diff td {
+ font-family: monospace;
+ white-space: pre;
+}
+
+div#cgit table.diff td div.head {
+ font-weight: bold;
+ margin-top: 1em;
+ color: black;
+}
+
+div#cgit table.diff td div.hunk {
+ color: #009;
+}
+
+div#cgit table.diff td div.add {
+ color: green;
+}
+
+div#cgit table.diff td div.del {
+ color: red;
+}
+
+div#cgit .sha1 {
+ font-family: monospace;
+ font-size: 90%;
+}
+
+div#cgit .left {
+ text-align: left;
+}
+
+div#cgit .right {
+ text-align: right;
+}
+
+div#cgit table.list td.reposection {
+ font-style: italic;
+ color: #888;
+}
+
+div#cgit a.button {
+ font-size: 80%;
+ padding: 0em 0.5em;
+}
+
+div#cgit a.primary {
+ font-size: 100%;
+}
+
+div#cgit a.secondary {
+ font-size: 90%;
+}
+
+div#cgit td.toplevel-repo {
+
+}
+
+div#cgit table.list td.sublevel-repo {
+ padding-left: 1.5em;
+}
+
+div#cgit ul.pager {
+ list-style-type: none;
+ text-align: center;
+ margin: 1em 0em 0em 0em;
+ padding: 0;
+}
+
+div#cgit ul.pager li {
+ display: inline-block;
+ margin: 0.25em 0.5em;
+}
+
+div#cgit ul.pager a {
+ color: #777;
+}
+
+div#cgit ul.pager .current {
+ font-weight: bold;
+}
+
+div#cgit span.age-mins {
+ font-weight: bold;
+ color: #080;
+}
+
+div#cgit span.age-hours {
+ color: #080;
+}
+
+div#cgit span.age-days {
+ color: #040;
+}
+
+div#cgit span.age-weeks {
+ color: #444;
+}
+
+div#cgit span.age-months {
+ color: #888;
+}
+
+div#cgit span.age-years {
+ color: #bbb;
+}
+
+div#cgit span.insertions {
+ color: #080;
+}
+
+div#cgit span.deletions {
+ color: #800;
+}
+
+div#cgit div.footer {
+ margin-top: 0.5em;
+ text-align: center;
+ font-size: 80%;
+ color: #ccc;
+}
+
+div#cgit div.footer a {
+ color: #ccc;
+ text-decoration: none;
+}
+
+div#cgit div.footer a:hover {
+ text-decoration: underline;
+}
+
+div#cgit a.branch-deco {
+ color: #000;
+ margin: 0px 0.5em;
+ padding: 0px 0.25em;
+ background-color: #88ff88;
+ border: solid 1px #007700;
+}
+
+div#cgit a.tag-deco {
+ color: #000;
+ margin: 0px 0.5em;
+ padding: 0px 0.25em;
+ background-color: #ffff88;
+ border: solid 1px #777700;
+}
+
+div#cgit a.tag-annotated-deco {
+ color: #000;
+ margin: 0px 0.5em;
+ padding: 0px 0.25em;
+ background-color: #ffcc88;
+ border: solid 1px #777700;
+}
+
+div#cgit a.remote-deco {
+ color: #000;
+ margin: 0px 0.5em;
+ padding: 0px 0.25em;
+ background-color: #ccccff;
+ border: solid 1px #000077;
+}
+
+div#cgit a.deco {
+ color: #000;
+ margin: 0px 0.5em;
+ padding: 0px 0.25em;
+ background-color: #ff8888;
+ border: solid 1px #770000;
+}
+
+div#cgit div.commit-subject a.branch-deco,
+div#cgit div.commit-subject a.tag-deco,
+div#cgit div.commit-subject a.tag-annotated-deco,
+div#cgit div.commit-subject a.remote-deco,
+div#cgit div.commit-subject a.deco {
+ margin-left: 1em;
+ font-size: 75%;
+}
+
+div#cgit table.stats {
+ border: solid 1px black;
+ border-collapse: collapse;
+}
+
+div#cgit table.stats th {
+ text-align: left;
+ padding: 1px 0.5em;
+ background-color: #eee;
+ border: solid 1px black;
+}
+
+div#cgit table.stats td {
+ text-align: right;
+ padding: 1px 0.5em;
+ border: solid 1px black;
+}
+
+div#cgit table.stats td.total {
+ font-weight: bold;
+ text-align: left;
+}
+
+div#cgit table.stats td.sum {
+ color: #c00;
+ font-weight: bold;
+/* background-color: #eee; */
+}
+
+div#cgit table.stats td.left {
+ text-align: left;
+}
+
+div#cgit table.vgraph {
+ border-collapse: separate;
+ border: solid 1px black;
+ height: 200px;
+}
+
+div#cgit table.vgraph th {
+ background-color: #eee;
+ font-weight: bold;
+ border: solid 1px white;
+ padding: 1px 0.5em;
+}
+
+div#cgit table.vgraph td {
+ vertical-align: bottom;
+ padding: 0px 10px;
+}
+
+div#cgit table.vgraph div.bar {
+ background-color: #eee;
+}
+
+div#cgit table.hgraph {
+ border: solid 1px black;
+ width: 800px;
+}
+
+div#cgit table.hgraph th {
+ background-color: #eee;
+ font-weight: bold;
+ border: solid 1px black;
+ padding: 1px 0.5em;
+}
+
+div#cgit table.hgraph td {
+ vertical-align: middle;
+ padding: 2px 2px;
+}
+
+div#cgit table.hgraph div.bar {
+ background-color: #eee;
+ height: 1em;
+}
+
+div#cgit table.ssdiff {
+ width: 100%;
+}
+
+div#cgit table.ssdiff td {
+ font-size: 75%;
+ font-family: monospace;
+ white-space: pre;
+ padding: 1px 4px 1px 4px;
+ border-left: solid 1px #aaa;
+ border-right: solid 1px #aaa;
+}
+
+div#cgit table.ssdiff td.add {
+ color: black;
+ background: #cfc;
+ min-width: 50%;
+}
+
+div#cgit table.ssdiff td.add_dark {
+ color: black;
+ background: #aca;
+ min-width: 50%;
+}
+
+div#cgit table.ssdiff span.add {
+ background: #cfc;
+ font-weight: bold;
+}
+
+div#cgit table.ssdiff td.del {
+ color: black;
+ background: #fcc;
+ min-width: 50%;
+}
+
+div#cgit table.ssdiff td.del_dark {
+ color: black;
+ background: #caa;
+ min-width: 50%;
+}
+
+div#cgit table.ssdiff span.del {
+ background: #fcc;
+ font-weight: bold;
+}
+
+div#cgit table.ssdiff td.changed {
+ color: black;
+ background: #ffc;
+ min-width: 50%;
+}
+
+div#cgit table.ssdiff td.changed_dark {
+ color: black;
+ background: #cca;
+ min-width: 50%;
+}
+
+div#cgit table.ssdiff td.lineno {
+ color: black;
+ background: #eee;
+ text-align: right;
+ width: 3em;
+ min-width: 3em;
+}
+
+div#cgit table.ssdiff td.hunk {
+ color: black;
+ background: #ccf;
+ border-top: solid 1px #aaa;
+ border-bottom: solid 1px #aaa;
+}
+
+div#cgit table.ssdiff td.head {
+ border-top: solid 1px #aaa;
+ border-bottom: solid 1px #aaa;
+}
+
+div#cgit table.ssdiff td.head div.head {
+ font-weight: bold;
+ color: black;
+}
+
+div#cgit table.ssdiff td.foot {
+ border-top: solid 1px #aaa;
+ border-left: none;
+ border-right: none;
+ border-bottom: none;
+}
+
+div#cgit table.ssdiff td.space {
+ border: none;
+}
+
+div#cgit table.ssdiff td.space div {
+ min-height: 3em;
+}
+
+@media only screen and (max-width: 800px) {
+ /* FORMS */
+ /* hide forms */
+ div#cgit td.form {
+ display: none;
+ }
+
+ /* HEADER */
+ /* wrap title text */
+ div#cgit table#header td.main {
+ white-space: normal;
+ }
+ /* Don't display author (save space) */
+ div#cgit table#header td.sub.right {
+ display: none;
+ }
+
+ /* CONTENT */
+ div#cgit div.content {
+ overflow-x: auto;
+ padding: 0.5em;
+ }
+ td.ls-mode {
+ white-space: nowrap;
+ }
+
+ /* TABLES */
+ div#cgit table.nowrap td {
+ white-space: normal;
+ }
+ div#cgit table.list td {
+ vertical-align: top;
+ }
+ div#cgit {
+ span.age-mins, span.age-hours, span.age-days, span.age-weeks, span.age-months, span.age-years {
+ white-space: nowrap;
+ }
+ }
+
+
+ /* PANEL ALIGNMENT */
+ div#cgit div.cgit-panel {
+ float: left;
+ }
+} \ No newline at end of file
diff --git a/config/services/web/git/default.nix b/config/services/web/git/default.nix
new file mode 100644
index 0000000..5223927
--- /dev/null
+++ b/config/services/web/git/default.nix
@@ -0,0 +1,49 @@
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}:
+
+let
+ scanPath = "/srv/git";
+ gitconfig = ''
+ [safe]
+ directory = ${scanPath}/*
+ '';
+in
+{
+ services.cgit.default = {
+ enable = true;
+ inherit scanPath;
+ gitHttpBackend = {
+ enable = true;
+ checkExportOkFiles = false;
+ };
+ nginx.virtualHost = "git";
+ settings = {
+ head-include = "${./head.html}";
+ root-title = "repositories";
+ root-desc = "by Quentin Aristote";
+ root-readme = "${./about.html}";
+ source-filter = "${pkgs.cgit}/lib/cgit/filters/syntax-highlighting.py";
+ clone-prefix = "https://git.aristote.fr";
+ section-from-path = 1;
+ snapshots = "tar.gz tar.bz2 tar.xz"; # for nix support
+ enable-index-owner = 0;
+ };
+ };
+
+ services.nginx.virtualHosts.git = {
+ serverName = "git.${config.networking.domain}";
+ enableACME = true;
+ forceSSL = true;
+ locations."= /cgit.css".alias = lib.mkForce ./cgit.css;
+ };
+
+ # give access to the repos
+ users.users.cgit.extraGroups = [ "git" ];
+ ## for the http backend
+ systemd.services.fcgiwrap-cgit-default.environment.XDG_CONFIG_HOME =
+ "${pkgs.writeTextDir "git/config" gitconfig}";
+}
diff --git a/config/services/web/git/head.html b/config/services/web/git/head.html
new file mode 100644
index 0000000..44dca77
--- /dev/null
+++ b/config/services/web/git/head.html
@@ -0,0 +1 @@
+<meta name="viewport" content="width=device-width initial-scale=1.0"/>
diff --git a/config/services/web/quentin/default.nix b/config/services/web/quentin/default.nix
new file mode 100644
index 0000000..7194190
--- /dev/null
+++ b/config/services/web/quentin/default.nix
@@ -0,0 +1,20 @@
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}: {
+ services.nginx.virtualHosts.quentin = {
+ serverName = "quentin.${config.networking.domain}";
+ locations."/".root = "${pkgs.personal.webpage}";
+ forceSSL = true;
+ enableACME = true;
+ extraConfig = ''
+ add_header Cache-Control no-cache;
+ add_header Content-Security-Policy "default-src 'none'; form-action 'none'; frame-ancestors 'none'; font-src 'self'; img-src 'self'; style-src 'self' 'unsafe-inline';";
+ '';
+ };
+
+ # automatically fetch (non-structural) website updates when updating the system
+ personal.system.autoUpgrade.autoUpdateInputs = lib.mkOptionDefault ["personal-webpage/data"];
+}
diff --git a/config/services/web/rss/DeutschLernenDeutscheWelleBridge.php b/config/services/web/rss/DeutschLernenDeutscheWelleBridge.php
new file mode 100644
index 0000000..710f8e6
--- /dev/null
+++ b/config/services/web/rss/DeutschLernenDeutscheWelleBridge.php
@@ -0,0 +1,39 @@
+<?php
+
+class DeutschLernenDeutscheWelleBridge extends XPathAbstract {
+ const NAME = 'Deutsche Welle Lernen Bridge';
+ const URI = 'https://learngerman.dw.com/de/';
+ const DESCRIPTION = 'Cost-free German-learning material';
+ const MAINTAINER = 'Quentin Aristote';
+ const CACHE_TIMEOUT = 3600; // 24h
+
+ const PARAMETERS = [
+ '' => [
+ 'id' => [
+ 'name' => 'Identifier',
+ 'type' => 'text',
+ 'description' => 'An identifier of the shape [a-z]-[0-9]*. Found at the end of the target URL.',
+ 'exampleValue' => 's-60040484'
+ ]
+ ]
+ ];
+
+ const XPATH_EXPRESSION_ITEM = '//div[@class="teaser-wrap"]/a';
+ const XPATH_EXPRESSION_ITEM_TITLE = './@title';
+ const XPATH_EXPRESSION_ITEM_URI = './@href';
+ // not given
+ // const XPATH_EXPRESSION_ITEM_AUTHOR =
+ const XPATH_EXPRESSION_ITEM_TIMESTAMP = './/time/@datetime';
+ // requires javascript
+ // const XPATH_EXPRESSION_ITEM_ENCLOSURES = './figure/img[2]/@src';
+ const XPATH_EXPRESSION_ITEM_CATEGORIES = './div[2]/span[1]/text()';
+
+
+ public function getIcon() {
+ return 'https://learngerman.dw.com/favicon.png';
+ }
+
+ public function getSourceUrl() {
+ return self::URI . $this->getInput('id');
+ }
+}
diff --git a/config/services/web/rss/FipAlbumsBridge.php b/config/services/web/rss/FipAlbumsBridge.php
new file mode 100644
index 0000000..aa5e597
--- /dev/null
+++ b/config/services/web/rss/FipAlbumsBridge.php
@@ -0,0 +1,56 @@
+<?php
+
+$GLOBALS['DATE_FORMATTER'] = new IntlDateFormatter(
+ 'fr-FR',
+ IntlDateFormatter::FULL,
+ IntlDateFormatter::SHORT,
+ 'Etc/UTC',
+ IntlDateFormatter::GREGORIAN,
+ "d MMMM y"
+);
+
+class FipAlbumsBridge extends XPathAbstract {
+ const NAME = 'Fip Albums Bridge';
+ const URI = 'https://www.radiofrance.fr/fip/albums/';
+ const DESCRIPTION = 'Albums promoted by Fip.';
+ const MAINTAINER = 'Quentin Aristote';
+ const CACHE_TIMEOUT = 86400; // 6h
+
+ const PARAMETERS = [
+ '' => [
+ 'category' => [
+ 'name' => 'Category',
+ 'type' => 'text',
+ 'description' => 'See examples for available options.',
+ 'exampleValue' => 'can be empty, "selections" or "album-jazz-de-la-semaine"'
+ ]
+ ]
+ ];
+
+ const XPATH_EXPRESSION_ITEM = '//div[starts-with(@class, "CardSide ")]';
+ const XPATH_EXPRESSION_ITEM_TITLE = './/a/@aria-label';
+ const XPATH_EXPRESSION_ITEM_CONTENT = './/img/@alt';
+ const XPATH_EXPRESSION_ITEM_URI = './/a/@href';
+ const XPATH_EXPRESSION_ITEM_AUTHOR = './/div[starts-with(@class, "title-zone ")]/p[2]/text()';
+ const XPATH_EXPRESSION_ITEM_TIMESTAMP = './/div[starts-with(@class, "AdditionalInfos ")]/p[1]/text()';
+ const XPATH_EXPRESSION_ITEM_ENCLOSURES = './/img/@src';
+ const XPATH_EXPRESSION_ITEM_CATEGORIES = './/div[starts-with(@class, "AdditionalInfos ")]/p[2]/text()';
+
+ public function getSourceUrl() {
+ return self::URI . $this->getInput('category');
+ }
+
+ public function getIcon() {
+ return 'https://www.radiofrance.fr/dist/favicons/fip/favicon.png';
+ }
+
+ protected function formatItemTimestamp($value) {
+ $monthyear = explode(": ", $value)[1];
+ return $GLOBALS['DATE_FORMATTER']->parse('1 ' . $monthyear);
+ }
+
+ # enclosure links don't have an extension
+ protected function cleanMediaUrl($mediaUrl) {
+ return $mediaUrl;
+ }
+}
diff --git a/config/services/web/rss/MaisonDeLaRadioBridge.php b/config/services/web/rss/MaisonDeLaRadioBridge.php
new file mode 100644
index 0000000..7fd4b4f
--- /dev/null
+++ b/config/services/web/rss/MaisonDeLaRadioBridge.php
@@ -0,0 +1,137 @@
+<?php
+
+$GLOBALS['DATE_FORMATTER'] = new IntlDateFormatter(
+ 'fr-FR',
+ IntlDateFormatter::FULL,
+ IntlDateFormatter::SHORT,
+ 'Etc/UTC',
+ IntlDateFormatter::GREGORIAN,
+ "dd MMMM y EEEE hh'h'mm"
+);
+
+class MaisonDeLaRadioBridge extends XPathAbstract {
+ const NAME = 'Maison de la Radio Bridge';
+ const URI = 'https://www.maisondelaradioetdelamusique.fr/agenda';
+ const DESCRIPTION = 'Agenda of the Maison de la Radio et de la Musique.';
+ const MAINTAINER = 'Quentin Aristote';
+ const CACHE_TIMEOUT = 3600; // 1h
+
+ const FEED_SOURCE_URL = 'https://www.maisondelaradioetdelamusique.fr/agenda';
+ const XPATH_EXPRESSION_ITEM = '//div[@class="hero-header--agenda text-white"]';
+ const XPATH_EXPRESSION_ITEM_TITLE = './/div[@class="Bolder-Large-XL mb-5 field_title"]';
+ const XPATH_EXPRESSION_ITEM_URI = './/div[@class="d-flex"]//a/@href';
+ const XPATH_EXPRESSION_ITEM_AUTHOR = './/div[@class="d-flex flex-column"]/div[2]';
+ const XPATH_EXPRESSION_ITEM_TIMESTAMP = './/div[@class="date text-uppercase text-center"]';
+ const XPATH_EXPRESSION_ITEM_ENCLOSURES = './/div[@class="bg-wrapper"]/img/@src';
+ const XPATH_EXPRESSION_ITEM_CATEGORIES = './/div[@class="SurTitre mb-5 field_event_type"]/text()';
+
+ const PARAMETERS = array(
+ '' => array (
+ 'type' => array(
+ 'name' => 'Type',
+ 'type' => 'list',
+ 'title' => 'Concert types.',
+ 'values' => array(
+ 'Tous' => 0,
+ 'Concert' => 2543,
+ 'Émission en public' => 1270,
+ 'Évènement' => 1273,
+ 'Rencontre' => 1272,
+ 'Exposition' => 1768,
+ 'Festival' => 2544,
+ 'Conert jeune public' => 1482
+ )
+ ),
+ 'genre' => array(
+ 'name' => 'Genre',
+ 'type' => 'list',
+ 'title' => 'Music genre.',
+ 'values' => array(
+ 'Tous' => 0,
+ 'Symphonique' => '1207',
+ 'Opéra' => '1212',
+ 'Musique baroque' => '1208',
+ 'Musique chorale' => '1211',
+ 'Musique de film' => '2542',
+ 'Récital et musique de chambre' => '1210',
+ 'Orgue' => '1214',
+ 'Jazz' => '1761',
+ 'Création contemporaine' => '1215',
+ 'Concert Jeune public' => '2584',
+ 'Tournée' => '2583',
+ 'Pop, rock et électro' => '2541',
+ 'Concert Fip' => '1225',
+ 'Atelier musical' => '1258',
+ 'Masterclasse' => '1251',
+ 'Concerts du soir et avant-concerts pour les scolaires' => '2560',
+ 'Concerts jeune public pour le champ social' =>'2581'
+ )
+ ),
+ 'formation' => array(
+ 'name' => 'Formation',
+ 'type' => 'list',
+ 'title' => 'Performing formations.',
+ 'values' => array(
+ 'Tous' => 0,
+ 'Orchestre Philharmonique de Radio France' => '864%2B2660%2B3333',
+ 'Orchestre National de France' => '861%2B1786',
+ 'Chœur de Radio France' => '703%2B2946',
+ 'Maîtrise de Radio France' => '832%2B2947'
+ )
+ ),
+ 'chef' => array(
+ 'name' => 'Chef',
+ 'type' => 'number',
+ 'title' => 'ID of the conductor (optional).',
+ 'exampleValue' => '53',
+ ),
+ 'compositeur' => array(
+ 'name' => 'Compositeur',
+ 'type' => 'number',
+ 'title' => 'ID of the composer (optional).',
+ 'exampleValue' => '131',
+ ),
+ 'soliste' => array(
+ 'name' => 'Soliste',
+ 'type' => 'number',
+ 'title' => 'ID of the solist (optional).',
+ 'exampleValue' => '3064',
+ )
+ )
+ );
+
+ public function getSourceUrl() {
+ $query = 'layout=row' . '&a-partir=' . date('Y-m-d');
+ foreach(self::PARAMETERS[''] as $param => $paramSpec) {
+ $val = $this->getInput($param);
+ if($val != 0 && !is_null($val)) {
+ if($paramSpec['type'] == 'list') {
+ $assignmentOp = '[]=';
+ } else {
+ $assignmentOp = '=';
+ }
+ $query = $query . '&' . $param . $assignmentOp . $val;
+ }
+ }
+ return self::URI . '?' . $query;
+ }
+
+ public function getIcon() {
+ return 'https://rf-maisondelaradio-production.s3.eu-west-3.amazonaws.com/s3fs-public/mdlrfavicon22.ico';
+ }
+
+ protected function getExpressionItemContent() {
+ return 'string(.//div[contains(@class, "Serif-small")])';
+ }
+ protected function formatItemContent($value) {
+ $normalizedWhitespace = preg_replace('/\s\s+/m', ' ', $value);
+ return preg_replace('/\s*,/', ',', $normalizedWhitespace);
+ }
+
+ protected function getExpressionItemTimestamp() {
+ return 'normalize-space(concat(string(' . self::XPATH_EXPRESSION_ITEM_TIMESTAMP . '), .//div[@class="d-flex flex-column"]/div[1]))';
+ }
+ protected function formatItemTimestamp($value) {
+ return $GLOBALS['DATE_FORMATTER']->parse($value);
+ }
+}
diff --git a/config/services/web/rss/RandonavigoBridge.php b/config/services/web/rss/RandonavigoBridge.php
new file mode 100644
index 0000000..ebc64c2
--- /dev/null
+++ b/config/services/web/rss/RandonavigoBridge.php
@@ -0,0 +1,33 @@
+<?php
+
+class RandonavigoBridge extends XPathAbstract {
+ const NAME = 'Randonavigo Bridge';
+ const URI = 'https://www.randonavigo.fr/';
+ const DESCRIPTION = 'Hiking trails in Île-de-France.';
+ const MAINTAINER = 'Quentin Aristote';
+ const CACHE_TIMEOUT = 86400; // 24h
+
+ const FEED_SOURCE_URL = 'https://www.randonavigo.fr/';
+ const XPATH_EXPRESSION_ITEM = '//article';
+ const XPATH_EXPRESSION_ITEM_TITLE = './/h2/a/text()';
+ const XPATH_EXPRESSION_ITEM_CONTENT = './div/div[1]/div[2]/text()';
+ const XPATH_EXPRESSION_ITEM_URI = './a/@href';
+ const XPATH_EXPRESSION_ITEM_AUTHOR = './div/div[1]/div[1]/div/text()';
+ const XPATH_EXPRESSION_ITEM_TIMESTAMP = './a/@href';
+ const XPATH_EXPRESSION_ITEM_ENCLOSURES = './a//img/@src';
+ const XPATH_EXPRESSION_ITEM_CATEGORIES = './div/div[2]//a/@title';
+
+ public function getIcon() {
+ return 'https://www.randonavigo.fr/apple-touch-icon.png';
+ }
+
+ protected function formatItemTimestamp($value) {
+ $pattern = "/\/([0-9]+)/";
+ preg_match_all($pattern, $value, $matches);
+ return strtotime(join('-', $matches[1]));
+ }
+
+ protected function cleanMediaUrl($value) {
+ return $value;
+ }
+}
diff --git a/config/services/web/rss/default.nix b/config/services/web/rss/default.nix
new file mode 100644
index 0000000..8884aee
--- /dev/null
+++ b/config/services/web/rss/default.nix
@@ -0,0 +1,45 @@
+{
+ config,
+ lib,
+ ...
+}:
+let
+ cfg = config.services.rss-bridge;
+in
+{
+ services.rss-bridge = {
+ enable = true;
+ config.system.enabled_bridges = [ "Instagram" ];
+ extraBridges = [
+ {
+ name = "Randonavigo";
+ source = ./RandonavigoBridge.php;
+ }
+ {
+ name = "DeutschLernenDeutscheWelle";
+ source = ./DeutschLernenDeutscheWelleBridge.php;
+ }
+ # Music
+ {
+ name = "FipAlbums";
+ source = ./FipAlbumsBridge.php;
+ }
+ ## Concerts
+ {
+ name = "MaisonDeLaRadio";
+ source = ./MaisonDeLaRadioBridge.php;
+ }
+ ];
+ virtualHost = "rss";
+ };
+
+ services.nginx = lib.mkIf (cfg.virtualHost != null) {
+ virtualHosts.${cfg.virtualHost} = {
+ serverName = "rss.${config.networking.domain}";
+ forceSSL = true;
+ enableACME = true;
+ };
+ };
+
+ systemd.services.phpfpm-rss-bridge.personal.monitor = true;
+}
diff --git a/config/services/web/webkeydirectory/default.nix b/config/services/web/webkeydirectory/default.nix
new file mode 100644
index 0000000..cf96119
--- /dev/null
+++ b/config/services/web/webkeydirectory/default.nix
@@ -0,0 +1,25 @@
+{ config, ... }:
+
+let
+ webkeydirectoryPath = "/.well-known/openpgpkey/${config.networking.domain}";
+in
+{
+ services.nginx.virtualHosts.webkeydirectory = {
+ serverName = "openpgpkey.${config.networking.domain}";
+ locations = {
+ "${webkeydirectoryPath}/hu/" = {
+ alias = "${./hu}/";
+ extraConfig = ''
+ default_type "application/octet-stream";
+ add_header Access-Control-Allow-Origin * always;
+ '';
+ };
+ "=${webkeydirectoryPath}/policy".alias = builtins.toFile "policy" "";
+ "/".extraConfig = ''
+ return 444;
+ '';
+ };
+ forceSSL = true;
+ enableACME = true;
+ };
+}
diff --git a/config/services/web/webkeydirectory/hu/44hqjnz5rw4mrr9d18fmecyskbmwxetw b/config/services/web/webkeydirectory/hu/44hqjnz5rw4mrr9d18fmecyskbmwxetw
new file mode 100644
index 0000000..ba11e50
--- /dev/null
+++ b/config/services/web/webkeydirectory/hu/44hqjnz5rw4mrr9d18fmecyskbmwxetw
Binary files differ