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.
This commit is contained in:
parent
cb692e0014
commit
b797481e2d
|
@ -2,9 +2,6 @@
|
||||||
with import <stockholm/lib>;
|
with import <stockholm/lib>;
|
||||||
let
|
let
|
||||||
# see https://github.com/zeropingheroes/lancache for full docs
|
# see https://github.com/zeropingheroes/lancache for full docs
|
||||||
cachedir = "/var/lancache/cache";
|
|
||||||
logdir = "/var/lancache/log";
|
|
||||||
|
|
||||||
lancache= pkgs.stdenv.mkDerivation rec {
|
lancache= pkgs.stdenv.mkDerivation rec {
|
||||||
name = "lancache-2017-06-26";
|
name = "lancache-2017-06-26";
|
||||||
src = pkgs.fetchFromGitHub {
|
src = pkgs.fetchFromGitHub {
|
||||||
|
@ -21,13 +18,14 @@ let
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
cp -r * $out/
|
cp -r * $out/
|
||||||
sed -i -e 's/^\(user\).*/\1 ${cfg.user} ${cfg.group};/' \
|
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 = {
|
cfg = {
|
||||||
group = "nginx-lancache";
|
group = "nginx-lancache";
|
||||||
user = "nginx-lancache";
|
user = "nginx-lancache";
|
||||||
stateDir = "/var/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"
|
||||||
|
@ -44,27 +42,23 @@ in {
|
||||||
restartIfChanged = true;
|
restartIfChanged = true;
|
||||||
|
|
||||||
preStart = ''
|
preStart = ''
|
||||||
PATH_CACHE="/var/lancache/cache"
|
mkdir -p ${cfg.statedir} && cd ${cfg.statedir}
|
||||||
PATH_LOGS="/var/lancache/logs"
|
PATH_CACHE=$PATH_BASE/cache
|
||||||
WWW_USER="${cfg.user}"
|
PATH_LOGS=$PATH_BASE/logs
|
||||||
WWW_GROUP="${cfg.group}"
|
|
||||||
|
|
||||||
mkdir -p $PATH_CACHE
|
mkdir -p cache/{installers,tmp} logs
|
||||||
cd $PATH_CACHE
|
rm -f conf; ln -s ${lancache} conf
|
||||||
mkdir -p installers tmp
|
chown -R ${cfg.user}:${cfg.group} .
|
||||||
mkdir -p $PATH_LOGS
|
|
||||||
|
|
||||||
chown -R $WWW_USER:$WWW_USER $PATH_CACHE
|
|
||||||
chown -R $WWW_USER:$WWW_USER $PATH_LOGS
|
|
||||||
'';
|
'';
|
||||||
serviceConfig = {
|
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";
|
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
RestartSec = "10s";
|
RestartSec = "10s";
|
||||||
StartLimitInterval = "1min";
|
StartLimitInterval = "1min";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
environment.etc.nginx.source = lancache;
|
||||||
users.extraUsers = (singleton
|
users.extraUsers = (singleton
|
||||||
{ name = cfg.user;
|
{ name = cfg.user;
|
||||||
group = cfg.group;
|
group = cfg.group;
|
||||||
|
|
Loading…
Reference in a new issue