diff --git a/disable-react-for-admin.patch b/disable-react-for-admin.patch deleted file mode 100644 index d3f16f0..0000000 --- a/disable-react-for-admin.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/app/Console/Commands/CreateAccount.php b/app/Console/Commands/CreateAccount.php -index 228f8e8283..1ff3c54a61 100644 ---- a/app/Console/Commands/CreateAccount.php -+++ b/app/Console/Commands/CreateAccount.php -@@ -79,7 +79,7 @@ class CreateAccount extends Command - $company->save(); - - $account->default_company_id = $company->id; -- $account->set_react_as_default_ap = true; -+ $account->set_react_as_default_ap = false; - $account->save(); - - $email = $this->option('email') ?? 'admin@example.com'; diff --git a/package.nix b/package.nix index d711968..b25d8a5 100644 --- a/package.nix +++ b/package.nix @@ -1,37 +1,109 @@ -{ lib -, php -, openssl -, writers +{ buildNpmPackage +, npmHooks , fetchFromGitHub +, fetchNpmDeps +, php82 +, nodejs_22 +, npm-lockfile-fix , dataDir ? "/var/lib/invoiceninja" , runtimeDir ? "/run/invoiceninja" }: -php.buildComposerProject (finalAttrs: { +let pname = "invoiceninja"; - version = "5.12.13"; + version = "5.13.19"; src = fetchFromGitHub { - owner = "invoiceninja"; - repo = "invoiceninja"; - rev = "v${finalAttrs.version}"; - hash = "sha256-/+dmZUxDeC33bBuM2oZwU9wOVtJY0X5/dkhlpbfLkYg="; + name = "${pname}"; + owner = pname; + repo = pname; + rev = "v${version}"; + hash = "sha256-pvZNTiGGX6OqOEqcDrDqqpLD1Ohc/TA4nIRjm2jEp74="; + + postFetch = '' + # add missing integrity fields to lockfile + ${npm-lockfile-fix}/bin/npm-lockfile-fix $out/package-lock.json + ''; }; - vendorHash = "sha256-NzFOh3XpKC3Ia1Ns9I6xN9N6y1F5dFSEk7bxq/eKZIc="; + uiVersion = "03.05.2026.1"; + uiSrc = fetchFromGitHub { + name = "${pname}-ui"; + owner = pname; + repo = "ui"; + tag = uiVersion; + hash = "sha256-BTaWNHTE+9NvavUYs56DdJHmqXy36N5k/crj3rU2Npg="; - patches = [ - ./disable-react-for-admin.patch + postFetch = '' + # add missing integrity fields to lockfile + ${npm-lockfile-fix}/bin/npm-lockfile-fix $out/package-lock.json + ''; + }; + + # React frontend + ui = buildNpmPackage { + pname = "${pname}-ui"; + version = uiVersion; + src = uiSrc; + + nodejs = nodejs_22; + + npmDepsHash = "sha256-JA5TfXeg7iHVjQdjeU6SSD2JFSLISad8hPowaR1roQw="; + + preConfigure = '' + sed -i 's/VITE_IS_TEST=true/VITE_IS_TEST=false/' .env.example + + cp .env.example .env + cp ${src}/vite.config.ts.react ./vite.config.js + ''; + + installPhase = '' + runHook preInstall + + mkdir $out + cp -a * $out + + runHook postInstall + ''; + }; +in + +php82.buildComposerProject (finalAttrs: { + inherit src version; + pname = "${pname}-composer"; + + nativeBuildInputs = [ + nodejs_22 + npmHooks.npmConfigHook + npmHooks.npmBuildHook ]; + vendorHash = "sha256-2CyWKlyCyoCt/WdY7Ta0oEXW2KIkGwhilHtzpBJ5Wnk="; + # Upstream composer.json has invalid license, webpatser/laravel-countries package is pointing # to commit-ref, and php required in require and require-dev composerStrictValidation = false; + CYPRESS_INSTALL_BINARY = 0; + + npmDeps = fetchNpmDeps { + name = "${pname}-${version}-npm-deps"; + inherit src; + hash = "sha256-WCadsQVj9eusYWJEOaEp5DIkVcbmPFGe6bmKi9NZDDg="; + }; + + preConfigure = '' + cp -r ${ui}/dist/* public/ + cp public/index.html resources/views/react/index.blade.php + ''; + postInstall = '' mv "$out/share/php/${finalAttrs.pname}"/* $out - rm -R $out/bootstrap/cache + # Remove JS/CSS build artifacts + rm -rf $out/node_modules + + rm -r $out/bootstrap/cache rm -rf $out/public/storage # Move static contents for the NixOS module to pick it up, if needed. @@ -44,16 +116,4 @@ php.buildComposerProject (finalAttrs: { ln -s ${dataDir}/storage/app/public $out/public/storage ln -s ${runtimeDir} $out/bootstrap ''; - - meta = { - description = "Open-source, self-hosted invoicing application"; - homepage = "https://www.invoiceninja.com/"; - license = with lib.licenses; { - fullName = "Elastic License 2.0"; - shortName = "Elastic-2.0"; - free = false; - }; - platforms = lib.platforms.all; - }; }) -