From 3e3c1754a5954c6847168af13b1ee421768650a5 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Thu, 1 Oct 2020 15:01:49 +0200 Subject: [PATCH] Work around nginx problem in 20.03 --- examples/nixos-unit/arion-compose.nix | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/examples/nixos-unit/arion-compose.nix b/examples/nixos-unit/arion-compose.nix index c88bac6..1edd4e5 100644 --- a/examples/nixos-unit/arion-compose.nix +++ b/examples/nixos-unit/arion-compose.nix @@ -19,10 +19,15 @@ { services.webserver = { config, pkgs, ... }: { - nixos.configuration = {config, pkgs, ...}: { + nixos.configuration = {config, lib, options, pkgs, ...}: { boot.isContainer = true; - services.nginx.enable = true; - services.nginx.virtualHosts.localhost.root = "${pkgs.nix.doc}/share/doc/nix/manual"; + services.nginx = { + enable = true; + virtualHosts.localhost.root = "${pkgs.nix.doc}/share/doc/nix/manual"; + } // lib.optionalAttrs (options?services.nginx.stateDir) { + # Work around a problem in NixOS 20.03 + stateDir = "/var/lib/nginx"; + }; system.build.run-nginx = pkgs.writeScript "run-nginx" '' #!${pkgs.bash}/bin/bash PATH='${config.systemd.services.nginx.environment.PATH}' @@ -30,8 +35,8 @@ echo nginx:x:${toString config.users.groups.nginx.gid}:nginx >>/etc/group echo 'nobody:x:65534:65534:Unprivileged account do not use:/var/empty:/run/current-system/sw/bin/nologin' >>/etc/passwd echo 'nogroup:x:65534:' >>/etc/group - mkdir -p /var/log/nginx /run/nginx/ /var/cache/nginx - chown nginx /var/log/nginx /run/nginx/ /var/cache/nginx + mkdir -p /var/log/nginx /run/nginx/ /var/cache/nginx /var/lib/nginx/{,logs,proxy_temp,client_body_temp,fastcgi_temp,scgi_temp,uwsgi_temp} + chown nginx /var/log/nginx /run/nginx/ /var/cache/nginx /var/lib/nginx/{,logs,proxy_temp,client_body_temp,fastcgi_temp,scgi_temp,uwsgi_temp} ${config.systemd.services.nginx.runner} ''; };