From 9bd7f9ebf4055534ace98002a1a9ddbb243805d1 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 28 Jun 2017 08:46:55 +0200 Subject: ma lancache: fix nginx prefix issues nginx is unable to have a config with relativ paths and a statedir somewhere else. this is why i now prepare the 'prefix' with everything in it. --- makefu/2configs/lancache.nix | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'makefu') diff --git a/makefu/2configs/lancache.nix b/makefu/2configs/lancache.nix index 8ec40136..ff5b0d78 100644 --- a/makefu/2configs/lancache.nix +++ b/makefu/2configs/lancache.nix @@ -2,9 +2,6 @@ with import ; let # see https://github.com/zeropingheroes/lancache for full docs - cachedir = "/var/lancache/cache"; - logdir = "/var/lancache/log"; - lancache= pkgs.stdenv.mkDerivation rec { name = "lancache-2017-06-26"; src = pkgs.fetchFromGitHub { @@ -21,13 +18,14 @@ let mkdir -p $out cp -r * $out/ sed -i -e 's/^\(user\).*/\1 ${cfg.user} ${cfg.group};/' \ - -e 's/^\(error_log\).*/\1 stderr;\ndaemon off;/' $out/nginx.conf + -e '1 idaemon off;' \ + $out/nginx.conf ''; }; cfg = { group = "nginx-lancache"; user = "nginx-lancache"; - stateDir = "/var/lancache"; + statedir = "/var/lancache"; package = pkgs.stdenv.lib.overrideDerivation pkgs.nginx (old:{ configureFlags = old.configureFlags ++ [ "--with-http_slice_module" @@ -44,27 +42,23 @@ in { restartIfChanged = true; preStart = '' - PATH_CACHE="/var/lancache/cache" - PATH_LOGS="/var/lancache/logs" - WWW_USER="${cfg.user}" - WWW_GROUP="${cfg.group}" - - mkdir -p $PATH_CACHE - cd $PATH_CACHE - mkdir -p installers tmp - mkdir -p $PATH_LOGS + mkdir -p ${cfg.statedir} && cd ${cfg.statedir} + PATH_CACHE=$PATH_BASE/cache + PATH_LOGS=$PATH_BASE/logs - chown -R $WWW_USER:$WWW_USER $PATH_CACHE - chown -R $WWW_USER:$WWW_USER $PATH_LOGS + mkdir -p cache/{installers,tmp} logs + rm -f conf; ln -s ${lancache} conf + chown -R ${cfg.user}:${cfg.group} . ''; serviceConfig = { - ExecStart = "${cfg.package}/bin/nginx -c ${lancache}/nginx.conf -p ${lancache}"; + ExecStart = "${cfg.package}/bin/nginx -p ${cfg.statedir}"; ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; Restart = "always"; RestartSec = "10s"; StartLimitInterval = "1min"; }; }; + environment.etc.nginx.source = lancache; users.extraUsers = (singleton { name = cfg.user; group = cfg.group; -- cgit v1.2.3