3 Commits

Author SHA1 Message Date
awkawb e89c4acf1c Merge branch 'master' of gitea.awkawb.cloud:awkawb/invoiceninja-nixos 2025-03-01 11:10:22 -05:00
awkawb ac6f82af6c test 2025-01-04 10:51:24 -05:00
awkawb 0be9eafd10 more tests 2025-01-04 09:37:58 -05:00
12 changed files with 11430 additions and 158 deletions
+45
View File
@@ -0,0 +1,45 @@
####
# Target definitions
####
# Disable echoing of target recipe commands
# Comment this for debugging
.SILENT:
# Run target recipes in one shell invocation
.ONESHELL:
# Since all targets are phony, all targets should be listed here
# One target per line
.PHONY: boot-vm \
build-vm \
clean \
format-nix-files \
help
# Show the help text
help:
egrep -h '\s##\s' $(MAKEFILE_LIST) \
| sort \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
format-nix-files: ## Format nix files using the nixpkgs-fmt tool
find . -name "*.nix" -exec nixpkgs-fmt {} \;
clean: ## Clean build artifacts and shutdown running virtual machines
rm result > /dev/null 2>&1
rm nixos.qcow2 > /dev/null 2>&1
pkill qemu
exit 0
build-vm: clean ## Build virtual machine for testing
nix build ".#nixosConfigurations.test.config.system.build.vm"
boot-vm: ## Run virtual machine in current terminal
QEMU_KERNEL_PARAMS=console=ttyS0 \
QEMU_NET_OPTS=hostfwd=tcp::8080-:80 \
QEMU_OPTS=-nographic \
./result/bin/run-nixos-vm
reset
+13
View File
@@ -0,0 +1,13 @@
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';
Generated
+4 -4
View File
@@ -140,16 +140,16 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1779102034,
"narHash": "sha256-vZJZjLo513IeI8hjzHFc6TDezUd4uCE2Eq4SNO3DNNg=",
"lastModified": 1740339700,
"narHash": "sha256-cbrw7EgQhcdFnu6iS3vane53bEagZQy/xyIkDWpCgVE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "687f05a9184cad4eaf905c48b63649e3a86f5433",
"rev": "04ef94c4c1582fd485bbfdb8c4a8ba250e359195",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-25.11",
"ref": "nixos-24.11",
"repo": "nixpkgs",
"type": "github"
}
+1 -1
View File
@@ -1,7 +1,7 @@
{
description = "An Invoice Ninja package and module.";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
outputs =
{ self, nixpkgs, nix, }:
-33
View File
@@ -1,33 +0,0 @@
set quiet := true
# Passed to QEMU in boot-vm
export QEMU_KERNEL_PARAMS := "console=ttyS0"
export QEMU_NET_OPTS := "hostfwd=tcp::8080-:80"
export QEMU_OPTS := "-nographic"
[private]
_default:
just --list
[doc('Clean build artifacts and shutdown running virtual machines')]
[group('maintenance')]
clean:
#!/usr/bin/env bash
rm result > /dev/null 2>&1
rm nixos.qcow2 > /dev/null 2>&1
pkill qemu
exit 0
[doc('Build virtual machine for testing')]
[group('main')]
build-vm: clean
nom build ".#nixosConfigurations.test.config.system.build.vm"
[doc('Run virtual machine in current terminal')]
[group('main')]
boot-vm:
#!/usr/bin/env bash
[ -x result/bin/run-nixos-vm ] && \
./result/bin/run-nixos-vm
reset
+17 -30
View File
@@ -498,42 +498,28 @@ in
addSSL = lib.mkForce (if (cfg.hostname == "localhost") then false else true);
enableACME = lib.mkForce (if (cfg.hostname == "localhost") then false else true);
locations = {
# Handle Laravel Routes
"/".tryFiles = "$uri $uri/ /index.php?$query_string";
# PHP Processing
"~ \\.php$".extraConfig = ''
include ${config.services.nginx.package}/conf/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
"/".extraConfig = ''
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?q=$1 last;
}
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' '*';
add_header 'Access-Control-Max-Age' 0;
add_header 'Content-Length' 0;
add_header 'Access-Control-Allow-Headers' 'X-API-COMPANY-KEY,X-API-SECRET,X-API-TOKEN,X-API-PASSWORD,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Disposition,Content-Type,Range,X-CSRF-TOKEN,X-XSRF-TOKEN,X-LIVEWIRE';
add_header 'Access-Control-Expose-Headers' 'X-APP-VERSION,X-MINIMUM-CLIENT-VERSION,X-CSRF-TOKEN,X-XSRF-TOKEN,X-LIVEWIRE';
add_header 'Access-Control-Allow-Credentials' false;
'';
"~ \\.php$".extraConfig = "return 403;";
"= /index.php".extraConfig = ''
fastcgi_pass unix:${config.services.phpfpm.pools.invoiceninja.socket};
fastcgi_index index.php;
'';
# Security: Deny access to hidden files
"~ /\\.ht".extraConfig = "deny all;";
# Static Files Caching
"~* \\.(jpg|jpeg|png|gif|ico|css|js)$".extraConfig = ''
expires 1y;
add_header Cache-Control "public, immutable";
'';
};
extraConfig = ''
index index.php index.html index.htm;
index index.html index.htm index.php;
error_page 404 /index.php;
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?q= last;
}
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' '*';
add_header 'Access-Control-Max-Age' 0;
add_header 'Content-Length' 0;
add_header 'Access-Control-Allow-Headers' 'X-API-COMPANY-KEY,X-API-SECRET,X-API-TOKEN,X-API-PASSWORD,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Disposition,Content-Type,Range,X-CSRF-TOKEN,X-XSRF-TOKEN,X-LIVEWIRE';
add_header 'Access-Control-Expose-Headers' 'X-APP-VERSION,X-MINIMUM-CLIENT-VERSION,X-CSRF-TOKEN,X-XSRF-TOKEN,X-LIVEWIRE';
add_header 'Access-Control-Allow-Credentials' false;
'';
}
(lib.mkIf (cfg.hostname != "localhost") {
@@ -567,8 +553,9 @@ in
hostName = lib.mkForce proto_hostname;
extraConfig = ''
encode zstd gzip
root ${invoiceninja}/public
root * ${invoiceninja}/public
php_fastcgi unix/${config.services.phpfpm.pools.invoiceninja.socket}
try_files {path} /index.html
header {
Access-Control-Allow-Origin "*"
Access-Control-Allow-Methods "*"
+11216
View File
File diff suppressed because it is too large Load Diff
+42
View File
@@ -0,0 +1,42 @@
{
"name": "@invoiceninja/invoiceninja",
"private": true,
"scripts": {
"dev": "vite --host 0.0.0.0",
"build": "vite build",
"production": "vite build"
},
"devDependencies": {
"@babel/compat-data": "7.15.0",
"@babel/plugin-proposal-class-properties": "^7.14.5",
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/forms": "^0.5.7",
"@tailwindcss/line-clamp": "^0.4.4",
"@tailwindcss/typography": "^0.5.10",
"autoprefixer": "^10.4.18",
"laravel-mix-purgecss": "^6.0.0",
"laravel-vite-plugin": "^0.8.0",
"postcss": "^8.4.35",
"tailwindcss": "^3.4.1",
"vite": "^4.4.9",
"vite-plugin-static-copy": "^0.17.0",
"vue-template-compiler": "^2.6.14"
},
"dependencies": {
"axios": "^0.25",
"card-js": "^1.0.13",
"card-validator": "^8.1.1",
"clipboard": "^2.0.10",
"cross-env": "^7.0.3",
"jsignature": "^2.1.3",
"json-formatter-js": "^2.3.4",
"laravel-mix": "^6.0.34",
"linkify-urls": "^4.0.0",
"lodash": "^4.17.21",
"resolve-url-loader": "^4.0.0",
"sass": "^1.43.4",
"sass-loader": "^12.3.0",
"signature_pad": "^5.0.2"
},
"type": "module"
}
+26 -86
View File
@@ -1,109 +1,37 @@
{ buildNpmPackage
, npmHooks
{ lib
, php
, openssl
, writers
, fetchFromGitHub
, fetchNpmDeps
, php82
, nodejs_22
, npm-lockfile-fix
, dataDir ? "/var/lib/invoiceninja"
, runtimeDir ? "/run/invoiceninja"
}:
let
php.buildComposerProject (finalAttrs: {
pname = "invoiceninja";
version = "5.11.41";
version = "5.13.19";
src = fetchFromGitHub {
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
'';
owner = "invoiceninja";
repo = "invoiceninja";
rev = "v${finalAttrs.version}";
hash = "sha256-6fCuNv+PIlUe9fOZwP6VfLuomSlUTmBiF/bjxKfs9Ig=";
};
uiVersion = "03.05.2026.1";
uiSrc = fetchFromGitHub {
name = "${pname}-ui";
owner = pname;
repo = "ui";
tag = uiVersion;
hash = "sha256-BTaWNHTE+9NvavUYs56DdJHmqXy36N5k/crj3rU2Npg=";
vendorHash = "sha256-KoBJJU0ViX99dNVxO8/7gk2SuDwuXbcHkqI5CpiHoLE=";
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
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;
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.
@@ -116,4 +44,16 @@ php82.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;
};
})
+25
View File
@@ -0,0 +1,25 @@
{ lib, fetchzip, buildNpmPackage, typescript }:
buildNpmPackage rec {
pname = "invoiceninja-react-ui";
version = "11.12.2024.1";
src = fetchzip {
url = "https://github.com/invoiceninja/ui/archive/refs/tags/11.12.2024.1.tar.gz";
hash = "sha256-6yAX+NM3ryWmn1Cww3vtsyjdyzzNtKxmiDMOTwu9JXc=";
};
npmDepsHash = "sha256-uqa/fzUlchMVzHiZuC7BXMVS/2rj0ukREecg4iDULWs=";
installPhase = ''
runHook preInstall
mkdir -p $out/share
cp -a dist $out/share/${pname}
runHook postInstall
'';
}
+38
View File
@@ -0,0 +1,38 @@
{ lib
, buildNpmPackage
, importNpmLock
, fetchFromGitHub
, dataDir ? "/var/lib/invoiceninja"
, runtimeDir ? "/run/invoiceninja"
}:
buildNpmPackage rec {
pname = "invoiceninja-react";
version = "5.11.7";
src = fetchFromGitHub {
owner = "invoiceninja";
repo = "invoiceninja";
rev = "v${version}";
hash = "sha256-wfKYe31ZulXJfbY5naFipXUhP0W6KUYbaoMuiV8DTas=";
};
npmDeps = importNpmLock {
package = lib.importJSON ./package.json;
packageLock = lib.importJSON ./package-lock.json;
};
npmConfigHook = importNpmLock.npmConfigHook;
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;
};
})
+3 -4
View File
@@ -1,4 +1,4 @@
{ pkgs, modulesPath, ... }:
{ modulesPath, ... }:
{
imports = [
@@ -6,7 +6,7 @@
../nixos-module/invoiceninja.nix
];
system.stateVersion = "25.11";
system.stateVersion = "24.11";
nixpkgs.config.allowUnfree = true;
@@ -18,10 +18,9 @@
services.invoiceninja = {
enable = true;
proxy.server = "nginx";
proxy.server = "caddy";
adminAccount.passwordFile = ./invoice_ninja_test_password;
secretFile = ./test.env;
settings.APP_DEBUG = true;
};
networking.firewall.enable = false;