nixpkgs/pkgs/servers/grocy/0001-Define-configs-with-env-vars.patch
2023-08-02 06:44:36 +02:00

84 lines
2.9 KiB
Diff

From 3ec6fce101083d4f23641fd015cbe4ade317ad59 Mon Sep 17 00:00:00 2001
From: Ember Keske <git@n0emis.eu>
Date: Wed, 2 Aug 2023 06:36:02 +0200
Subject: [PATCH 1/2] Define configs with env vars
---
app.php | 6 +++---
services/DatabaseService.php | 2 +-
services/FilesService.php | 2 +-
services/StockService.php | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/app.php b/app.php
index 31905be6..30b3eb82 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';
@@ -63,7 +63,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) {
@@ -103,7 +103,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/services/DatabaseService.php b/services/DatabaseService.php
index be5486b6..b6091ee7 100644
--- a/services/DatabaseService.php
+++ b/services/DatabaseService.php
@@ -104,6 +104,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 7d070350..a6dd4b08 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 16cb468c..23228803 100644
--- a/services/StockService.php
+++ b/services/StockService.php
@@ -1769,7 +1769,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))
{
--
2.41.0