ma lancache: make statedir a variable

This commit is contained in:
makefu 2017-11-08 10:48:31 +01:00
parent 9f8aa6abae
commit 7184c97993
No known key found for this signature in database
GPG Key ID: 36F7711F3FC0F225

View File

@ -17,15 +17,21 @@ let
installPhase = '' installPhase = ''
mkdir -p $out mkdir -p $out
cp -r * $out/ cp -r * $out/
rm $out/caches-enabled/*
sed -i -e 's/^\(user\).*/\1 ${cfg.user} ${cfg.group};/' \ sed -i -e 's/^\(user\).*/\1 ${cfg.user} ${cfg.group};/' \
-e '1 idaemon off;' \ -e '1 idaemon off;' \
-e 's#/var/lancache#${cfg.statedir}#g' \
$out/nginx.conf $out/nginx.conf
sed -i -e 's#/var/lancache#${cfg.statedir}#g' \
$out/*/*.conf
ln -s $out/caches-available/* $out/caches-enabled/
''; '';
}; };
cfg = { cfg = {
statedir = "/data/cache";
group = "nginx-lancache"; group = "nginx-lancache";
user = "nginx-lancache"; user = "nginx-lancache";
statedir = "/var/lancache";
package = pkgs.stdenv.lib.overrideDerivation pkgs.nginx (old:{ package = pkgs.stdenv.lib.overrideDerivation pkgs.nginx (old:{
configureFlags = old.configureFlags ++ [ configureFlags = old.configureFlags ++ [
"--with-http_slice_module" "--with-http_slice_module"
@ -43,6 +49,7 @@ in {
preStart = '' preStart = ''
mkdir -p ${cfg.statedir} && cd ${cfg.statedir} mkdir -p ${cfg.statedir} && cd ${cfg.statedir}
chmod 700 ${cfg.statedir}
PATH_CACHE=$PATH_BASE/cache PATH_CACHE=$PATH_BASE/cache
PATH_LOGS=$PATH_BASE/logs PATH_LOGS=$PATH_BASE/logs