Files
nixpkgs/pkgs/by-name/gr/grocy/0001-Define-configs-with-env-vars.patch
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

108 lines
4.2 KiB
Diff

From b1df18da8735ed8c043e5e63753a6524cce620e1 Mon Sep 17 00:00:00 2001
From: Chris Moultrie <tebriel@frodux.in>
Date: Tue, 4 Mar 2025 08:20:58 -0500
Subject: [PATCH 1/2] Define configs with env vars
---
app.php | 8 ++++----
controllers/BaseApiController.php | 2 +-
services/DatabaseService.php | 2 +-
services/FilesService.php | 2 +-
services/StockService.php | 2 +-
5 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/app.php b/app.php
index 9cdd14e5..c0b30b6e 100644
--- a/app.php
+++ b/app.php
@@ -12,7 +12,7 @@ use Slim\Views\Blade;
require_once __DIR__ . '/packages/autoload.php';
// Load config files
-require_once GROCY_DATAPATH . '/config.php';
+require_once getenv('GROCY_CONFIG_FILE');
require_once __DIR__ . '/config-dist.php'; // For not in own config defined values we use the default ones
require_once __DIR__ . '/helpers/ConfigurationValidator.php';
@@ -52,7 +52,7 @@ catch (EInvalidConfig $ex)
}
// Create data/viewcache folder if it doesn't exist
-$viewcachePath = GROCY_DATAPATH . '/viewcache';
+$viewcachePath = getenv('GROCY_CACHE_DIR');
if (!file_exists($viewcachePath))
{
mkdir($viewcachePath);
@@ -85,7 +85,7 @@ $app = AppFactory::create();
$container = $app->getContainer();
$container->set('view', function (Container $container)
{
- return new Blade(__DIR__ . '/views', GROCY_DATAPATH . '/viewcache');
+ return new Blade(__DIR__ . '/views', getenv('GROCY_CACHE_DIR'));
});
$container->set('UrlManager', function (Container $container)
@@ -127,7 +127,7 @@ $errorMiddleware->setDefaultErrorHandler(
$app->add(new CorsMiddleware($app->getResponseFactory()));
-$app->getRouteCollector()->setCacheFile(GROCY_DATAPATH . '/viewcache/route_cache.php');
+$app->getRouteCollector()->setCacheFile(getenv('GROCY_CACHE_DIR') . '/route_cache.php');
ob_clean(); // No response output before here
$app->run();
diff --git a/controllers/BaseApiController.php b/controllers/BaseApiController.php
index 5941e348..9283ba93 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 c5914e49..c249a3bf 100644
--- a/services/DatabaseService.php
+++ b/services/DatabaseService.php
@@ -145,6 +145,6 @@ class DatabaseService
return GROCY_DATAPATH . '/grocy_' . $dbSuffix . '.db';
}
- return GROCY_DATAPATH . '/grocy.db';
+ return getenv('GROCY_DB_FILE');
}
}
diff --git a/services/FilesService.php b/services/FilesService.php
index 113a6478..61568bc6 100644
--- a/services/FilesService.php
+++ b/services/FilesService.php
@@ -10,7 +10,7 @@ class FilesService extends BaseService
public function __construct()
{
- $this->StoragePath = GROCY_DATAPATH . '/storage';
+ $this->StoragePath = getenv('GROCY_STORAGE_DIR');
if (!file_exists($this->StoragePath))
{
mkdir($this->StoragePath);
diff --git a/services/StockService.php b/services/StockService.php
index 2261db4e..cd438942 100644
--- a/services/StockService.php
+++ b/services/StockService.php
@@ -1752,7 +1752,7 @@ class StockService extends BaseService
// User plugins take precedence
$standardPluginPath = __DIR__ . "/../plugins/$pluginName.php";
- $userPluginPath = GROCY_DATAPATH . "/plugins/$pluginName.php";
+ $userPluginPath = getenv('GROCY_PLUGIN_DIR') . "/$pluginName.php";
if (file_exists($userPluginPath))
{
require_once $userPluginPath;
--
2.47.2