diff --git a/common/common.nix b/common/common.nix index 5fd9b58..f1244f5 100644 --- a/common/common.nix +++ b/common/common.nix @@ -14,7 +14,7 @@ ./server/nginx-stream.nix ./server/matrix.nix ./server/zerobin.nix - ./server/privatebin.nix + ./server/privatebin/privatebin.nix ./pc/de.nix ]; diff --git a/common/server/privatebin/privatebin.nix b/common/server/privatebin/privatebin.nix index cfd7191..8ab9738 100644 --- a/common/server/privatebin/privatebin.nix +++ b/common/server/privatebin/privatebin.nix @@ -2,6 +2,18 @@ let cfg = config.services.privatebin; + privateBinSrc = pkgs.stdenv.mkDerivation { + name = "privatebin"; + src = pkgs.fetchFromGitHub { + owner = "privatebin"; + repo = "privatebin"; + rev = "d65bf02d7819a530c3c2a88f6f9947651fe5258d"; + sha256 = "7ttAvEDL1ab0cUZcqZzXFkXwB2rF2t4eNpPxt48ap94="; + }; + installPhase = '' + cp -ar $src $out + ''; + }; in { options.services.privatebin = { enable = lib.mkEnableOption "enable privatebin"; @@ -24,19 +36,12 @@ in { services.nginx.virtualHosts.${cfg.host} = { enableACME = true; forceSSL = true; + locations."/" = { + root = privateBinSrc; + index = "index.php"; + }; locations."~ \.php$" = { - root = lib.mkDerivation { - name = "privatebin"; - src = lib.fetchFromGitHub { - owner = "privatebin"; - repo = "privatebin"; - rev = "d65bf02d7819a530c3c2a88f6f9947651fe5258d"; - # sha256 = ""; - }; - installPhase = '' - cp -ar $src $out - ''; - }; + root = privateBinSrc; extraConfig = '' fastcgi_pass unix:${config.services.phpfpm.pools.privatebin.socket}; fastcgi_index index.php; @@ -45,7 +50,7 @@ in { }; systemd.tmpfiles.rules = [ - "d '/var/lib/privatebin' 0750 ${user} ${group} - -" + "d '/var/lib/privatebin' 0750 privatebin privatebin - -" ]; services.phpfpm.pools.privatebin = { @@ -54,6 +59,15 @@ in { phpEnv = { CONFIG_PATH = "${./conf.php}"; }; + settings = { + pm = "dynamic"; + "listen.owner" = config.services.nginx.user; + "pm.max_children" = 5; + "pm.start_servers" = 2; + "pm.min_spare_servers" = 1; + "pm.max_spare_servers" = 3; + "pm.max_requests" = 500; + }; }; }; -} \ No newline at end of file +}