package.nix: updated to build Invoice Ninja with React frontend
This commit is contained in:
+66
-41
@@ -1,59 +1,84 @@
|
||||
{ lib
|
||||
, php
|
||||
, openssl
|
||||
, writers
|
||||
{ buildNpmPackage
|
||||
, fetchFromGitHub
|
||||
, importNpmLock
|
||||
, lib
|
||||
, openssl
|
||||
, php82
|
||||
, nodejs_22
|
||||
, symlinkJoin
|
||||
, writers
|
||||
, dataDir ? "/var/lib/invoiceninja"
|
||||
, runtimeDir ? "/run/invoiceninja"
|
||||
}:
|
||||
|
||||
php.buildComposerProject (finalAttrs: {
|
||||
let
|
||||
pname = "invoiceninja";
|
||||
version = "5.12.13";
|
||||
|
||||
version = "5.13.19";
|
||||
uiVersion = "03.05.2026.1";
|
||||
src = fetchFromGitHub {
|
||||
owner = "invoiceninja";
|
||||
repo = "invoiceninja";
|
||||
rev = "v${finalAttrs.version}";
|
||||
hash = "sha256-/+dmZUxDeC33bBuM2oZwU9wOVtJY0X5/dkhlpbfLkYg=";
|
||||
owner = pname;
|
||||
repo = pname;
|
||||
rev = "v${version}";
|
||||
hash = "sha256-PlFu9MQ4nZ2oHgSwOLffqERpZPIWkpgZ/qTqru63a9Y=";
|
||||
};
|
||||
uiSrc = fetchFromGitHub {
|
||||
owner = pname;
|
||||
repo = "ui";
|
||||
tag = uiVersion;
|
||||
hash = "sha256-aEqYX/YNUV5UR631X4zQyqoXSSuUqvILplV8Mm557Bc=";
|
||||
};
|
||||
|
||||
vendorHash = "sha256-NzFOh3XpKC3Ia1Ns9I6xN9N6y1F5dFSEk7bxq/eKZIc=";
|
||||
# PHP composer
|
||||
composer = php82.buildComposerProject (finalAttrs: {
|
||||
inherit src version;
|
||||
pname = "${pname}-composer";
|
||||
|
||||
patches = [
|
||||
./disable-react-for-admin.patch
|
||||
];
|
||||
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;
|
||||
# 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;
|
||||
|
||||
postInstall = ''
|
||||
mv "$out/share/php/${finalAttrs.pname}"/* $out
|
||||
rm -R $out/bootstrap/cache
|
||||
postInstall = ''mv "$out/share/php/${finalAttrs.pname}"/* $out'';
|
||||
});
|
||||
|
||||
# React frontend
|
||||
ui = buildNpmPackage {
|
||||
pname = "${pname}-ui";
|
||||
version = uiVersion;
|
||||
src = uiSrc;
|
||||
|
||||
rm -rf $out/public/storage
|
||||
nodejs = nodejs_22;
|
||||
|
||||
#npmDepsHash = "sha256-T2/0POKcr4x98cy3rfeNyTIBZrHuLfqpC1J6nymGcys=";
|
||||
|
||||
# Move static contents for the NixOS module to pick it up, if needed.
|
||||
mv $out/bootstrap $out/bootstrap-static
|
||||
mv $out/storage $out/storage-static
|
||||
#npmPackFlags = [ "--ignore-scripts" ];
|
||||
#npmInstallFlags = [ "--omit=dev" ];
|
||||
|
||||
# Link NixOS module files to derivation output
|
||||
ln -s ${dataDir}/.env $out/.env
|
||||
ln -s ${dataDir}/storage $out/
|
||||
ln -s ${dataDir}/storage/app/public $out/public/storage
|
||||
ln -s ${runtimeDir} $out/bootstrap
|
||||
'';
|
||||
npmConfigHook = importNpmLock.npmConfigHook;
|
||||
#npmDeps = importNpmLock {
|
||||
# package = builtins.readFile ./. + "/package.json";
|
||||
# packageLock = builtins.readFile ./. + "/package-lock.json";
|
||||
#};
|
||||
npmDeps = importNpmLock { npmRoot = ./.; };
|
||||
|
||||
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;
|
||||
prePatch = ''
|
||||
sed -i 's/VITE_IS_TEST=true/VITE_IS_TEST=false/' .env.example
|
||||
cp .env.example .env
|
||||
|
||||
# This will make the build output a single bundle file (bundle.[hash].js)
|
||||
cp ${composer}/vite.config.ts.react ./vite.config.js
|
||||
|
||||
#${npm-lockfile-fix}/bin/npm-lockfile-fix ./package-lock.json
|
||||
'';
|
||||
};
|
||||
})
|
||||
|
||||
invoiceNinja = symlinkJoin {
|
||||
name = "invoiceninja";
|
||||
paths = [
|
||||
composer
|
||||
ui
|
||||
];
|
||||
};
|
||||
in ui
|
||||
|
||||
|
||||
Reference in New Issue
Block a user