From 8f2268782b34835a4b73a9d26200113e9a02a544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Tue, 16 Jan 2024 23:50:59 +0200 Subject: [PATCH] caddy --- flake.nix | 6 ++++-- modules/e11sync/default.nix | 9 ++++++++- vm.nix | 10 ++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 641b487..d3bd92f 100644 --- a/flake.nix +++ b/flake.nix @@ -53,8 +53,6 @@ inherit geoip2-tarball; }; - e11sync-module = import ./modules/e11sync e11sync-backend; - e11sync-static = pkgs.callPackage ./pkgs/e11sync-static.nix {}; e11sync-frontend = pkgs.callPackage ./pkgs/e11sync-frontend.nix { @@ -64,6 +62,10 @@ e11sync-backend = pkgs.callPackage ./pkgs/e11sync-backend.nix { inherit geoip-mmdb e11sync-static; }; + + e11sync-module = import ./modules/e11sync { + inherit e11sync-backend e11sync-frontend; + }; in { packages = { inherit geoip-mmdb; diff --git a/modules/e11sync/default.nix b/modules/e11sync/default.nix index 1f6fa17..18c02f1 100644 --- a/modules/e11sync/default.nix +++ b/modules/e11sync/default.nix @@ -1,4 +1,7 @@ -e11sync-backend: { +{ + e11sync-backend, + e11sync-frontend, +}: { config, lib, ... @@ -22,6 +25,7 @@ e11sync-backend: { type = path; default = "/var/lib/e11sync-backend/db.sqlite3"; }; + vhost = lib.mkOption {type = str;}; }; config = let @@ -74,5 +78,8 @@ e11sync-backend: { ]; }; }; + + services.caddy.virtualHosts."${cfg.vhost}".extraConfig = + builtins.readFile "${e11sync-frontend}"; }; } diff --git a/vm.nix b/vm.nix index 3262701..ad42f1c 100644 --- a/vm.nix +++ b/vm.nix @@ -3,6 +3,16 @@ enable = true; migrateOnStart = true; secretKeyPath = "unsafe"; + vhost = ":8001"; + }; + + services.caddy = { + enable = true; + globalConfig = '' + http_port 8001 + auto_https off + debug + ''; }; environment.systemPackages = with pkgs; [