From 4f54941f05813092e550722f8f99eaeb25839e3b Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 7 Aug 2024 21:39:13 +0200 Subject: [PATCH] nix: replace domain --- derivation.nix | 4 ++-- flake.nix | 4 ++-- module.nix | 14 +++++++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/derivation.nix b/derivation.nix index 4b0b94d..6ed41d2 100644 --- a/derivation.nix +++ b/derivation.nix @@ -1,4 +1,4 @@ -{ domain, mkPnpmPackage, static ? false }: +{ contentApi, mkPnpmPackage, static ? false }: mkPnpmPackage { src = ./.; @@ -7,7 +7,7 @@ mkPnpmPackage { postPatch = '' substituteInPlace src/app/api/api.domain.ts \ - --replace 'http://127.0.0.1:8080' 'https://content.${domain}' + --replace 'http://127.0.0.1:8080' '${contentApi}' ''; script = if static then "build:static" else "build:ci"; diff --git a/flake.nix b/flake.nix index 9d301f1..58eb37b 100644 --- a/flake.nix +++ b/flake.nix @@ -20,11 +20,11 @@ { packages = rec { website = pkgs.callPackage ./derivation.nix { - domain = "dd-ix.net"; + contentApi = "content.dd-ix.net"; mkPnpmPackage = pnpm2nix.packages."${system}".mkPnpmPackage; }; website-static = pkgs.callPackage ./derivation.nix { - domain = "dd-ix.net"; + contentApi = "content.dd-ix.net"; static = true; mkPnpmPackage = pnpm2nix.packages."${system}".mkPnpmPackage; }; diff --git a/module.nix b/module.nix index 3f34f9e..acfc49b 100644 --- a/module.nix +++ b/module.nix @@ -2,6 +2,9 @@ let cfg = config.dd-ix.website; + package = cfg.package.override { + inherit (cfg) contentApi; + }; in { options.dd-ix.website = { @@ -13,6 +16,11 @@ in type = lib.types.str; description = "The domain the frontend should be served."; }; + + contentApi = lib.mkOption { + type = lib.types.str; + description = "The domain the content api is listening."; + }; }; config = lib.mkIf cfg.enable { @@ -21,11 +29,11 @@ in wantedBy = [ "multi-user.target" ]; environment = { - APP_DIR = "${pkgs.website}"; + APP_DIR = package; }; serviceConfig = { - ExecStart = "${pkgs.nodejs}/bin/node ${cfg.package}/server.mjs"; + ExecStart = "${pkgs.nodejs}/bin/node ${package}/server.mjs"; DynamicUser = true; Restart = "always"; }; @@ -36,7 +44,7 @@ in virtualHosts."${cfg.domain}".locations = { "/" = { - root = "${cfg.package}/browser"; + root = "${package}/browser"; # just something that does not exists index = "X6XewZMsmreGIxx1lCdp0Yo1X4qHTivW"; tryFiles = "$uri @website";