From bd1bc16fff51ec5fcef78ac636af2a9b9d782feb Mon Sep 17 00:00:00 2001 From: Luna Simons Date: Sun, 28 Jan 2024 22:59:58 +0100 Subject: [PATCH] feat: added redis unix socket support --- .env.example | 6 ++++-- default.nix | 4 +++- module.nix | 8 ++++++++ src/app.module.ts | 1 + 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index e0f6fbd..5bf150b 100644 --- a/.env.example +++ b/.env.example @@ -3,8 +3,10 @@ UNTIS_USERNAME= UNTIS_PASSWORD= UNTIS_BASEURL= -BULL_REDIS_HOST= -BULL_REDIS_PORT= +BULL_REDIS_HOST=localhost +BULL_REDIS_PORT=6379 +# or +#BULL_REDIS_PATH=/run/redis/redis.sock #MAINTENANCE_TITLE= #MAINTENANCE_DESCRIPTION= diff --git a/default.nix b/default.nix index 551622e..a6d8139 100644 --- a/default.nix +++ b/default.nix @@ -13,7 +13,7 @@ mkYarnPackage rec { offlineCache = fetchYarnDeps { yarnLock = src + "/yarn.lock"; - hash = "sha256-NHghkf5Nziyz3M7E4941sV5JFqY7RYMTlZqYsQPZLpU="; + hash = "sha256-mToEmc4cNd2fsyT/DUkzMiO4BYUDw6aexbcXOVfB2ds="; }; nativeBuildInputs = [makeWrapper]; @@ -30,6 +30,8 @@ mkYarnPackage rec { --add-flags "$out/libexec/untis-ics-sync/deps/untis-ics-sync/dist/main.js" ''; + dontStrip = true; + meta = with lib; { description = "Serves a calendar API (ICS) for events provided from Untis"; homepage = "https://github.com/bddvlpr/untis-ics-sync"; diff --git a/module.nix b/module.nix index bdff6d0..2a1a065 100644 --- a/module.nix +++ b/module.nix @@ -40,12 +40,20 @@ in { serviceConfig = { Restart = "on-failure"; ExecStart = "${lib.getExe cfg.package}"; + Environment = [ + "BULL_REDIS_PATH=${config.services.redis.servers.untis-ics-sync.unixSocket}" + ]; EnvironmentFile = cfg.envFile; User = cfg.user; Group = cfg.group; }; }; + services.redis.servers.untis-ics-sync = { + enable = true; + user = cfg.user; + }; + users = { users.untis-ics-sync = lib.mkIf (cfg.user == "untis-ics-sync") { isSystemUser = true; diff --git a/src/app.module.ts b/src/app.module.ts index 8f1834c..da9ea00 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -18,6 +18,7 @@ import { BullModule } from '@nestjs/bull'; redis: { host: configService.get('BULL_REDIS_HOST'), port: configService.get('BULL_REDIS_PORT'), + path: configService.get('BULL_REDIS_PATH'), }, }), }),