From 9010db4f75107d9d96c804c3cd5d8ce700de620c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Sun, 12 Jul 2020 00:01:10 +0100 Subject: [PATCH] Add website service --- etc/nixos/configuration.nix | 1 + etc/nixos/derivations/tlaternet | 1 + etc/nixos/derivations/tlaternet-templates | 1 + etc/nixos/services/tlaternet.nix | 45 +++++++++++++++++++++++ 4 files changed, 48 insertions(+) create mode 160000 etc/nixos/derivations/tlaternet create mode 160000 etc/nixos/derivations/tlaternet-templates create mode 100644 etc/nixos/services/tlaternet.nix diff --git a/etc/nixos/configuration.nix b/etc/nixos/configuration.nix index a26f5de..b0d8c61 100644 --- a/etc/nixos/configuration.nix +++ b/etc/nixos/configuration.nix @@ -14,6 +14,7 @@ ./services/nginx.nix ./services/gitlab.nix ./services/nextcloud.nix + ./services/tlaternet.nix ]; networking = { diff --git a/etc/nixos/derivations/tlaternet b/etc/nixos/derivations/tlaternet new file mode 160000 index 0000000..bb19002 --- /dev/null +++ b/etc/nixos/derivations/tlaternet @@ -0,0 +1 @@ +Subproject commit bb19002f511e7ffe54fc2375562e32ed9526c740 diff --git a/etc/nixos/derivations/tlaternet-templates b/etc/nixos/derivations/tlaternet-templates new file mode 160000 index 0000000..1160d96 --- /dev/null +++ b/etc/nixos/derivations/tlaternet-templates @@ -0,0 +1 @@ +Subproject commit 1160d96b064531f65290e2d665c7c8d05fc3d29a diff --git a/etc/nixos/services/tlaternet.nix b/etc/nixos/services/tlaternet.nix new file mode 100644 index 0000000..7292e86 --- /dev/null +++ b/etc/nixos/services/tlaternet.nix @@ -0,0 +1,45 @@ +{ pkgs, ... }: + +let + tlaternet = import ../derivations/tlaternet { inherit pkgs; }; + tlaternet-templates = import ../derivations/tlaternet-templates { inherit pkgs; }; + +in +{ + networked-docker-containers = { + web = { + image = "tlaternet/web"; + imageFile = pkgs.dockerTools.buildImage { + name = "tlaternet/web"; + tag = "latest"; + contents = tlaternet; + config = { + Cmd = [ "${tlaternet}/bin/tlaternet" ]; + Volumes = { + "/srv/mail" = {}; + }; + Env = [ + "ROCKET_PORT=80" + "ROCKET_TEMPLATE_DIR=${tlaternet-templates}/srv/web" + ]; + ExposedPorts = { + "80" = {}; + }; + }; + }; + volumes = [ + "mail:/srv/mail" + ]; + environment = { + VIRTUAL_HOST = "tlater.net,www.tlater.net"; + LETSENCRYPT_HOST = "tlater.net,www.tlater.net"; + }; + networks = [ + "webproxy" + ]; + extraDockerOptions = [ + "--domainname=tlater.net" + ]; + }; + }; +}