Skip to content

Commit d6c7fa9

Browse files
committed
grocy: 4.0.3 -> 4.2.0, build from sources
The adjusted patch have been taken from #288602. Changes: https://github.com/grocy/grocy/releases/tag/v4.1.0 https://github.com/grocy/grocy/releases/tag/v4.2.0
1 parent f98e5d6 commit d6c7fa9

3 files changed

+72
-29
lines changed

pkgs/servers/grocy/0001-Define-configs-with-env-vars.patch

+21-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Subject: [PATCH 1/2] Define configs with env vars
1111
4 files changed, 6 insertions(+), 6 deletions(-)
1212

1313
diff --git a/app.php b/app.php
14-
index bc5b1b39..26f7687e 100644
14+
index bc5b1b3..26f7687 100644
1515
--- a/app.php
1616
+++ b/app.php
1717
@@ -12,7 +12,7 @@ use Slim\Views\Blade;
@@ -41,11 +41,24 @@ index bc5b1b39..26f7687e 100644
4141

4242
ob_clean(); // No response output before here
4343
$app->run();
44+
diff --git a/controllers/BaseApiController.php b/controllers/BaseApiController.php
45+
index 5941e348..e5b02af4 100644
46+
--- a/controllers/BaseApiController.php
47+
+++ b/controllers/BaseApiController.php
48+
@@ -162,7 +162,7 @@ class BaseApiController extends BaseController
49+
if (self::$htmlPurifierInstance == null)
50+
{
51+
$htmlPurifierConfig = \HTMLPurifier_Config::createDefault();
52+
- $htmlPurifierConfig->set('Cache.SerializerPath', GROCY_DATAPATH . '/viewcache');
53+
+ $htmlPurifierConfig->set('Cache.SerializerPath', getenv('GROCY_CACHE_DIR'));
54+
$htmlPurifierConfig->set('HTML.Allowed', 'div,b,strong,i,em,u,a[href|title|target],iframe[src|width|height|frameborder],ul,ol,li,p[style],br,span[style],img[style|width|height|alt|src],table[border|width|style],tbody,tr,td,th,blockquote,*[style|class|id],h1,h2,h3,h4,h5,h6');
55+
$htmlPurifierConfig->set('Attr.EnableID', true);
56+
$htmlPurifierConfig->set('HTML.SafeIframe', true);
4457
diff --git a/services/DatabaseService.php b/services/DatabaseService.php
45-
index 4a05bda1..ce41ed17 100644
58+
index ba79a73..12a851a 100644
4659
--- a/services/DatabaseService.php
4760
+++ b/services/DatabaseService.php
48-
@@ -125,6 +125,6 @@ class DatabaseService
61+
@@ -137,6 +137,6 @@ class DatabaseService
4962
return GROCY_DATAPATH . '/grocy_' . $dbSuffix . '.db';
5063
}
5164

@@ -54,7 +67,7 @@ index 4a05bda1..ce41ed17 100644
5467
}
5568
}
5669
diff --git a/services/FilesService.php b/services/FilesService.php
57-
index 7d070350..a6dd4b08 100644
70+
index 7d07035..a6dd4b0 100644
5871
--- a/services/FilesService.php
5972
+++ b/services/FilesService.php
6073
@@ -10,7 +10,7 @@ class FilesService extends BaseService
@@ -67,18 +80,18 @@ index 7d070350..a6dd4b08 100644
6780
{
6881
mkdir($this->StoragePath);
6982
diff --git a/services/StockService.php b/services/StockService.php
70-
index 7265e82b..13af591a 100644
83+
index 9f034a5..fd3c0b7 100644
7184
--- a/services/StockService.php
7285
+++ b/services/StockService.php
73-
@@ -1761,7 +1761,7 @@ class StockService extends BaseService
86+
@@ -1707,7 +1707,7 @@ class StockService extends BaseService
7487
throw new \Exception('No barcode lookup plugin defined');
7588
}
7689

7790
- $path = GROCY_DATAPATH . "/plugins/$pluginName.php";
7891
+ $path = getenv('GROCY_PLUGIN_DIR') . "/$pluginName.php";
79-
8092
if (file_exists($path))
8193
{
94+
require_once $path;
8295
--
83-
2.41.0
96+
2.42.0
8497

pkgs/servers/grocy/0002-Remove-check-for-config-file-as-it-s-stored-in-etc-g.patch

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ Subject: [PATCH 2/2] Remove check for config-file as it's stored in /etc/grocy
88
1 file changed, 1 deletion(-)
99

1010
diff --git a/helpers/PrerequisiteChecker.php b/helpers/PrerequisiteChecker.php
11-
index da431b4b..6b878627 100644
11+
index 8e12a5c..37b433d 100644
1212
--- a/helpers/PrerequisiteChecker.php
1313
+++ b/helpers/PrerequisiteChecker.php
14-
@@ -17,7 +17,6 @@ class PrerequisiteChecker
14+
@@ -18,7 +18,6 @@ class PrerequisiteChecker
1515
public function checkRequirements()
1616
{
1717
self::checkForPhpVersion();
@@ -20,5 +20,4 @@ index da431b4b..6b878627 100644
2020
self::checkForComposer();
2121
self::checkForPhpExtensions();
2222
--
23-
2.41.0
24-
23+
2.42.0

pkgs/servers/grocy/default.nix

+48-17
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,71 @@
1-
{ lib, stdenv, fetchurl, unzip, nixosTests }:
1+
{ lib
2+
, fetchFromGitHub
3+
, fetchYarnDeps
4+
, php
5+
, yarn
6+
, fixup-yarn-lock
7+
, nixosTests
8+
}:
29

3-
stdenv.mkDerivation rec {
10+
php.buildComposerProject (finalAttrs: {
411
pname = "grocy";
5-
version = "4.0.3";
12+
version = "4.2.0";
613

7-
src = fetchurl {
8-
url = "https://github.com/grocy/grocy/releases/download/v${version}/grocy_${version}.zip";
9-
hash = "sha256-KBTsi634SolgA01eRthMuWx7DIF7rhvJSPxiHyuKSR8=";
14+
src = fetchFromGitHub {
15+
owner = "grocy";
16+
repo = "grocy";
17+
rev = "v${finalAttrs.version}";
18+
hash = "sha256-aX3DMy9Jv8rNp1/VIvUtNXYXGBrCgBMs5GsDf4XXSj0=";
1019
};
1120

12-
nativeBuildInputs = [ unzip ];
13-
unpackPhase = ''
14-
unzip ${src} -d .
15-
'';
21+
vendorHash = "sha256-KaYvA0Rd4pd1s/L8QbVUgkE+SjH+jv4+6RvIaGOpews=";
22+
23+
offlineCache = fetchYarnDeps {
24+
yarnLock = finalAttrs.src + "/yarn.lock";
25+
hash = "sha256-UvWY8+qSRvzJbm7z3CmLyeUHxemzNUB7dHYP95ZVtcI=";
26+
};
27+
28+
nativeBuildInputs = [
29+
yarn
30+
fixup-yarn-lock
31+
];
32+
33+
# Upstream composer.json file is missing the name, description and license fields
34+
composerStrictValidation = false;
1635

1736
# NOTE: if patches are created from a git checkout, those should be modified
18-
# with `unixdos` to make sure those apply here.
37+
# with `unix2dos` to make sure those apply here.
1938
patches = [
2039
./0001-Define-configs-with-env-vars.patch
2140
./0002-Remove-check-for-config-file-as-it-s-stored-in-etc-g.patch
2241
];
23-
patchFlags = [ "--binary" "-p1" ];
2442

25-
dontBuild = true;
43+
configurePhase = ''
44+
runHook preConfigure
2645
27-
passthru.tests = { inherit (nixosTests) grocy; };
46+
export HOME=$(mktemp -d)
47+
yarn config --offline set yarn-offline-mirror $offlineCache
48+
fixup-yarn-lock yarn.lock
49+
yarn install --offline --frozen-lockfile --no-progress --non-interactive
50+
51+
runHook postConfigure
52+
'';
2853

2954
installPhase = ''
30-
mkdir -p $out/
31-
cp -R . $out/
55+
runHook preInstall
56+
57+
mv $out/share/php/grocy/* $out
58+
rm -r $out/share
59+
60+
runHook postInstall
3261
'';
3362

63+
passthru.tests = { inherit (nixosTests) grocy; };
64+
3465
meta = with lib; {
3566
license = licenses.mit;
3667
maintainers = with maintainers; [ n0emis ];
3768
description = "ERP beyond your fridge - grocy is a web-based self-hosted groceries & household management solution for your home";
3869
homepage = "https://grocy.info/";
3970
};
40-
}
71+
})

0 commit comments

Comments
 (0)