summaryrefslogtreecommitdiffstats
path: root/makefu/2configs/nginx
diff options
context:
space:
mode:
authorlassulus <lass@blue.r>2018-09-04 20:53:12 +0200
committerlassulus <lass@blue.r>2018-09-04 20:53:12 +0200
commit96c4ab61202f515c7a361ef76c398e542771d6b4 (patch)
treece2ca90d0ae800bb3ba3e1b05593e7ba7bef104c /makefu/2configs/nginx
parente183bb1c80c42131f9e3d932985e413ef457f77a (diff)
parent481376c1509661cbf1bdb17b9887b3a4f0487b6f (diff)
Merge remote-tracking branch 'gum/master'
Diffstat (limited to 'makefu/2configs/nginx')
-rw-r--r--makefu/2configs/nginx/rompr.nix76
1 files changed, 76 insertions, 0 deletions
diff --git a/makefu/2configs/nginx/rompr.nix b/makefu/2configs/nginx/rompr.nix
new file mode 100644
index 000000000..8c1fbc53b
--- /dev/null
+++ b/makefu/2configs/nginx/rompr.nix
@@ -0,0 +1,76 @@
+{ config, lib, pkgs, ... }:
+
+with import <stockholm/lib>;
+let
+ user = config.services.nginx.user;
+ group = config.services.nginx.group;
+ src = pkgs.fetchFromGitHub {
+ owner = "fatg3erman";
+ repo = "RompR";
+ rev = "1.21";
+ sha256 = "00gk2c610qgpsb6y296h9pz2aaa6gfq4cqhn15l7fdrk3lkvh01q";
+ };
+ fpm-socket = "/var/run/php5-rompr-fpm.sock";
+ mpd-src = "/var/lib/rompr";
+
+in {
+ services.phpfpm = {
+ # phpfpm does not have an enable option
+ poolConfigs = {
+ mpd = ''
+ user = ${user}
+ group = ${group}
+ listen = ${fpm-socket}
+ listen.owner = ${user}
+ listen.group = ${group}
+ pm = dynamic
+ pm.max_children = 5
+ pm.start_servers = 2
+ pm.min_spare_servers = 1
+ pm.max_spare_servers = 3
+ chdir = /
+ php_admin_value[error_log] = 'stderr'
+ php_admin_flag[log_errors] = on
+ catch_workers_output = yes
+ '';
+ };
+ };
+ # TODO: Pre-job
+ # TODO: prefs.var could be templated (serialized php ...) then we would not
+ # need to have a state dir at all
+ system.activationScripts.rompr = ''
+ mkdir -p ${mpd-src}
+ cp -r ${src}/. ${mpd-src}
+ chown -R ${user}:${group} ${mpd-src}
+ chmod 770 ${mpd-src}
+ '';
+ services.nginx = {
+ enable = mkDefault true;
+ virtualHosts = {
+ "localhost" = {
+ root = mpd-src;
+ locations."/".index = "index.php";
+ locations."~ \.php$" = {
+ root = mpd-src;
+ extraConfig = ''
+ client_max_body_size 200M;
+ fastcgi_pass unix:${fpm-socket};
+ include ${pkgs.nginx}/conf/fastcgi_params;
+ include ${pkgs.nginx}/conf/fastcgi.conf;
+ fastcgi_index index.php;
+ try_files $uri =404;
+ '';
+ };
+ };
+ };
+ };
+ services.mysql = {
+ enable = true;
+ package = pkgs.mariadb;
+ ensureDatabases = [ "romprdb" ];
+ ensureUsers = [
+ { ensurePermissions = { "romprdb.*" = "ALL PRIVILEGES"; };
+ name = user; }
+ ];
+ };
+}