Skip to content

Commit 71e1366

Browse files
committed
Fix Nix temp dir handling for ab-av1
1 parent 5c8d12c commit 71e1366

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

nix/module.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
PORT = toString cfg.port;
1515
DATABASE_PATH = cfg.databasePath;
1616
REENCODARR_DATA_DIR = toString cfg.dataDir;
17-
REENCODARR_TMPDIR = toString cfg.cacheDir;
17+
REENCODARR_TMPDIR = "${toString cfg.cacheDir}/tmp";
18+
TMPDIR = "${toString cfg.cacheDir}/tmp";
1819
}
1920
// cfg.extraEnvironment;
2021

@@ -225,6 +226,7 @@ in {
225226
systemd.tmpfiles.rules = [
226227
"d ${cfg.dataDir} 0750 ${cfg.user} ${cfg.group} - -"
227228
"d ${cfg.cacheDir} 0750 ${cfg.user} ${cfg.group} - -"
229+
"d ${cfg.cacheDir}/tmp 0750 ${cfg.user} ${cfg.group} - -"
228230
"d ${builtins.dirOf cfg.databasePath} 0750 ${cfg.user} ${cfg.group} - -"
229231
];
230232

@@ -247,7 +249,7 @@ in {
247249
User = cfg.user;
248250
Group = cfg.group;
249251
WorkingDirectory = cfg.dataDir;
250-
ReadWritePaths = [cfg.cacheDir cfg.dataDir (builtins.dirOf cfg.databasePath)];
252+
ReadWritePaths = [cfg.cacheDir "${cfg.cacheDir}/tmp" cfg.dataDir (builtins.dirOf cfg.databasePath)];
251253
LoadCredential = lib.optional (cfg.secretKeyBaseFile != null) "secret_key_base:${cfg.secretKeyBaseFile}";
252254
Nice = cfg.nice;
253255
IOSchedulingClass = cfg.ioSchedulingClass;

nix/package.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@ in
9393
postInstall = ''
9494
wrapProgram "$out/bin/reencodarr" \
9595
--run '
96+
if [ -z "''${TMPDIR:-}" ]; then
97+
if [ -n "''${REENCODARR_TMPDIR:-}" ]; then
98+
export TMPDIR="$REENCODARR_TMPDIR"
99+
elif [ -n "''${REENCODARR_DATA_DIR:-}" ]; then
100+
export TMPDIR="$REENCODARR_DATA_DIR/tmp"
101+
else
102+
export TMPDIR=/tmp/reencodarr_tmp
103+
fi
104+
fi
105+
mkdir -p "$TMPDIR"
96106
if [ -z "''${TZDATA_DATA_DIR:-}" ]; then
97107
if [ -n "''${REENCODARR_DATA_DIR:-}" ]; then
98108
export TZDATA_DATA_DIR="$REENCODARR_DATA_DIR/tzdata"

0 commit comments

Comments
 (0)