Skip to content

Commit

Permalink
nix: replace domain
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelCoding committed Aug 7, 2024
1 parent 4bab74f commit 4f54941
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions derivation.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ domain, mkPnpmPackage, static ? false }:
{ contentApi, mkPnpmPackage, static ? false }:

mkPnpmPackage {
src = ./.;
Expand All @@ -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";
Expand Down
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
14 changes: 11 additions & 3 deletions module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

let
cfg = config.dd-ix.website;
package = cfg.package.override {
inherit (cfg) contentApi;
};
in
{
options.dd-ix.website = {
Expand All @@ -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 {
Expand All @@ -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";
};
Expand All @@ -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";
Expand Down

0 comments on commit 4f54941

Please sign in to comment.