From 10287025aae680db17c032becd7db0ba56541597 Mon Sep 17 00:00:00 2001 From: jopejoe1 Date: Thu, 11 Jul 2024 14:10:10 +0200 Subject: [PATCH] infra: add web page --- nix/infra/nginx.nix | 3 +++ nix/web.nix | 28 ++++++++++++++++++++++++++-- web/package.json | 1 + 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/nix/infra/nginx.nix b/nix/infra/nginx.nix index a576ea2..56c2078 100644 --- a/nix/infra/nginx.nix +++ b/nix/infra/nginx.nix @@ -1,4 +1,6 @@ { + self, + config, ... }: @@ -13,6 +15,7 @@ "clan-war.net" = { enableACME = true; forceSSL = true; + locations."/".root = "${self.legacyPackages.${config.nixpkgs.hostPlatform.system}.web.override { withBackendUrl = "api.clan-war.net";}}/"; }; "api.clan-war.net" = { forceSSL = true; diff --git a/nix/web.nix b/nix/web.nix index 1551e77..bbc6530 100644 --- a/nix/web.nix +++ b/nix/web.nix @@ -2,6 +2,8 @@ stdenv, lib, pnpm, + nodejs, + withBackendUrl ? "" }: stdenv.mkDerivation (finalAttrs: { @@ -12,10 +14,32 @@ stdenv.mkDerivation (finalAttrs: { pnpmDeps = pnpm.fetchDeps { inherit (finalAttrs) pname version src; - hash = "sha256-dTXWbUDjmlIlMZ/sIFaInTRmVdWpyzJA4oadJAzUivs="; + hash = "sha256-sDeAAvBsYnZchMBCKFN3XODC65Y5mThLwO3//UqcDgI="; }; - nativeBuildInputs = [ pnpm.configHook ]; + nativeBuildInputs = [ + nodejs + pnpm.configHook + ]; + + env.VITE_BACKEND_URL = withBackendUrl; + + buildPhase = '' + runHook preBuild + + pnpm buildNoCheck + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out + cp -r dist/* $out + + runHook postInstall + ''; buildInputs = [ ]; diff --git a/web/package.json b/web/package.json index d21b823..c0d8d14 100644 --- a/web/package.json +++ b/web/package.json @@ -4,6 +4,7 @@ "scripts": { "dev": "vite --host", "build": "vue-tsc --noEmit && vite build", + "buildNoCheck": "vite build", "preview": "vite preview" }, "dependencies": {