Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grocy: 4.0.3 -> 4.2.0, build from sources #296686

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions pkgs/servers/grocy/0001-Define-configs-with-env-vars.patch
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Subject: [PATCH 1/2] Define configs with env vars
4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/app.php b/app.php
index bc5b1b39..26f7687e 100644
index bc5b1b3..26f7687 100644
--- a/app.php
+++ b/app.php
@@ -12,7 +12,7 @@ use Slim\Views\Blade;
Expand Down Expand Up @@ -41,11 +41,24 @@ index bc5b1b39..26f7687e 100644

ob_clean(); // No response output before here
$app->run();
diff --git a/controllers/BaseApiController.php b/controllers/BaseApiController.php
index 5941e348..e5b02af4 100644
--- a/controllers/BaseApiController.php
+++ b/controllers/BaseApiController.php
@@ -162,7 +162,7 @@ class BaseApiController extends BaseController
if (self::$htmlPurifierInstance == null)
{
$htmlPurifierConfig = \HTMLPurifier_Config::createDefault();
- $htmlPurifierConfig->set('Cache.SerializerPath', GROCY_DATAPATH . '/viewcache');
+ $htmlPurifierConfig->set('Cache.SerializerPath', getenv('GROCY_CACHE_DIR'));
$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');
$htmlPurifierConfig->set('Attr.EnableID', true);
$htmlPurifierConfig->set('HTML.SafeIframe', true);
diff --git a/services/DatabaseService.php b/services/DatabaseService.php
index 4a05bda1..ce41ed17 100644
index ba79a73..12a851a 100644
--- a/services/DatabaseService.php
+++ b/services/DatabaseService.php
@@ -125,6 +125,6 @@ class DatabaseService
@@ -137,6 +137,6 @@ class DatabaseService
return GROCY_DATAPATH . '/grocy_' . $dbSuffix . '.db';
}

Expand All @@ -54,7 +67,7 @@ index 4a05bda1..ce41ed17 100644
}
}
diff --git a/services/FilesService.php b/services/FilesService.php
index 7d070350..a6dd4b08 100644
index 7d07035..a6dd4b0 100644
--- a/services/FilesService.php
+++ b/services/FilesService.php
@@ -10,7 +10,7 @@ class FilesService extends BaseService
Expand All @@ -67,18 +80,18 @@ index 7d070350..a6dd4b08 100644
{
mkdir($this->StoragePath);
diff --git a/services/StockService.php b/services/StockService.php
index 7265e82b..13af591a 100644
index 9f034a5..fd3c0b7 100644
--- a/services/StockService.php
+++ b/services/StockService.php
@@ -1761,7 +1761,7 @@ class StockService extends BaseService
@@ -1707,7 +1707,7 @@ class StockService extends BaseService
throw new \Exception('No barcode lookup plugin defined');
}

- $path = GROCY_DATAPATH . "/plugins/$pluginName.php";
+ $path = getenv('GROCY_PLUGIN_DIR') . "/$pluginName.php";

if (file_exists($path))
{
require_once $path;
--
2.41.0
2.42.0

Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ Subject: [PATCH 2/2] Remove check for config-file as it's stored in /etc/grocy
1 file changed, 1 deletion(-)

diff --git a/helpers/PrerequisiteChecker.php b/helpers/PrerequisiteChecker.php
index da431b4b..6b878627 100644
index 8e12a5c..37b433d 100644
--- a/helpers/PrerequisiteChecker.php
+++ b/helpers/PrerequisiteChecker.php
@@ -17,7 +17,6 @@ class PrerequisiteChecker
@@ -18,7 +18,6 @@ class PrerequisiteChecker
public function checkRequirements()
{
self::checkForPhpVersion();
Expand All @@ -20,5 +20,4 @@ index da431b4b..6b878627 100644
self::checkForComposer();
self::checkForPhpExtensions();
--
2.41.0

2.42.0
65 changes: 48 additions & 17 deletions pkgs/servers/grocy/default.nix
Original file line number Diff line number Diff line change
@@ -1,40 +1,71 @@
{ lib, stdenv, fetchurl, unzip, nixosTests }:
{ lib
, fetchFromGitHub
, fetchYarnDeps
, php
, yarn
, fixup-yarn-lock
, nixosTests
}:

stdenv.mkDerivation rec {
php.buildComposerProject (finalAttrs: {
pname = "grocy";
version = "4.0.3";
version = "4.2.0";

src = fetchurl {
url = "https://github.com/grocy/grocy/releases/download/v${version}/grocy_${version}.zip";
hash = "sha256-KBTsi634SolgA01eRthMuWx7DIF7rhvJSPxiHyuKSR8=";
src = fetchFromGitHub {
owner = "grocy";
repo = "grocy";
rev = "v${finalAttrs.version}";
hash = "sha256-aX3DMy9Jv8rNp1/VIvUtNXYXGBrCgBMs5GsDf4XXSj0=";
};

nativeBuildInputs = [ unzip ];
unpackPhase = ''
unzip ${src} -d .
'';
vendorHash = "sha256-KaYvA0Rd4pd1s/L8QbVUgkE+SjH+jv4+6RvIaGOpews=";

offlineCache = fetchYarnDeps {
yarnLock = finalAttrs.src + "/yarn.lock";
hash = "sha256-UvWY8+qSRvzJbm7z3CmLyeUHxemzNUB7dHYP95ZVtcI=";
};

nativeBuildInputs = [
yarn
fixup-yarn-lock
];

# Upstream composer.json file is missing the name, description and license fields
composerStrictValidation = false;

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

dontBuild = true;
configurePhase = ''
runHook preConfigure

passthru.tests = { inherit (nixosTests) grocy; };
export HOME=$(mktemp -d)
yarn config --offline set yarn-offline-mirror $offlineCache
fixup-yarn-lock yarn.lock
yarn install --offline --frozen-lockfile --no-progress --non-interactive

runHook postConfigure
'';

installPhase = ''
mkdir -p $out/
cp -R . $out/
runHook preInstall

mv $out/share/php/grocy/* $out
rm -r $out/share

runHook postInstall
'';

passthru.tests = { inherit (nixosTests) grocy; };

meta = with lib; {
license = licenses.mit;
maintainers = with maintainers; [ n0emis ];
description = "ERP beyond your fridge - grocy is a web-based self-hosted groceries & household management solution for your home";
homepage = "https://grocy.info/";
};
}
})