From b0731caa940ffbdc02b95c5bb23685a063ee9a4d Mon Sep 17 00:00:00 2001 From: oddlama Date: Tue, 13 May 2025 20:13:34 +0200 Subject: [PATCH] ente-web: allow building any included application instead of just photos --- pkgs/by-name/en/ente-web/package.nix | 39 +++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/pkgs/by-name/en/ente-web/package.nix b/pkgs/by-name/en/ente-web/package.nix index 65b71e8b74a8..e48e115a2af5 100644 --- a/pkgs/by-name/en/ente-web/package.nix +++ b/pkgs/by-name/en/ente-web/package.nix @@ -8,10 +8,17 @@ yarnBuildHook, nix-update-script, extraBuildEnv ? { }, + # This package contains serveral sub-applications. This specifies which of them you want to build. + enteApp ? "photos", + # Accessing some apps (such as account) directly will result in a hardcoded redirect to ente.io. + # To prevent users from accidentally logging in to ente.io instead of the selfhosted instance, you + # can set this parameter to override these occurrences with your own url. Must include the schema. + # Example: https://my-ente.example.com + enteMainUrl ? null, }: stdenv.mkDerivation (finalAttrs: { - pname = "ente-web"; + pname = "ente-web-${enteApp}"; version = "1.2.4"; src = fetchFromGitHub { @@ -38,14 +45,31 @@ stdenv.mkDerivation (finalAttrs: { # See: https://github.com/ente-io/ente/blob/main/web/apps/photos/.env env = extraBuildEnv; - installPhase = '' - runHook preInstall + # Replace hardcoded ente.io urls if desired + postPatch = lib.optionalString (enteMainUrl != null) '' + substituteInPlace \ + apps/payments/src/services/billing.ts \ + apps/photos/src/pages/shared-albums.tsx \ + --replace-fail "https://ente.io" ${lib.escapeShellArg enteMainUrl} - cp -r apps/photos/out $out - - runHook postInstall + substituteInPlace \ + apps/accounts/src/pages/index.tsx \ + --replace-fail "https://web.ente.io" ${lib.escapeShellArg enteMainUrl} ''; + yarnBuildScript = "build:${enteApp}"; + installPhase = + let + distName = if enteApp == "payments" then "dist" else "out"; + in + '' + runHook preInstall + + cp -r apps/${enteApp}/${distName} $out + + runHook postInstall + ''; + passthru.updateScript = nix-update-script { extraArgs = [ "--version-regex" @@ -54,12 +78,13 @@ stdenv.mkDerivation (finalAttrs: { }; meta = { - description = "Web client for Ente Photos"; + description = "Ente application web frontends"; homepage = "https://ente.io/"; changelog = "https://github.com/ente-io/ente/releases"; license = lib.licenses.agpl3Only; maintainers = with lib.maintainers; [ pinpox + oddlama ]; platforms = lib.platforms.all; };