pterodactyl panel and wings
This commit is contained in:
parent
f303253c62
commit
63d52c2fd4
6 changed files with 256 additions and 0 deletions
135
modules/panel.nix
Normal file
135
modules/panel.nix
Normal file
|
@ -0,0 +1,135 @@
|
|||
{ lib, config, pkgs, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.services.pterodactyl;
|
||||
pterodactlyPhp83 = (pkgs.php83.buildEnv {
|
||||
extensions = { enabled, all, }: enabled ++ (with all; [ redis xdebug ]);
|
||||
extraConfig = ''
|
||||
xdebug.mode=debug
|
||||
'';
|
||||
});
|
||||
in {
|
||||
options.services.pterodactyl = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
};
|
||||
nginxVhost = mkOption {
|
||||
type = types.str;
|
||||
description = mdDoc ''
|
||||
The Nginx virtual host, on which the panel will run.
|
||||
'';
|
||||
default = "localhost";
|
||||
example = literalExpression "mgr.matestmc.net";
|
||||
};
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
description = mdDoc ''
|
||||
The user that Nginx and the panel will run with.
|
||||
'';
|
||||
default = "pterodactyl";
|
||||
example = literalExpression "pterodactyl";
|
||||
};
|
||||
dataDir = mkOption {
|
||||
type = types.str;
|
||||
description = mdDoc ''
|
||||
The directory with the panel files.
|
||||
Usually /srv/pterodactyl or /var/www/pterodactyl.
|
||||
'';
|
||||
default = "/srv/pterodactyl";
|
||||
example = literalExpression "/srv/pterodactyl";
|
||||
};
|
||||
redisName = mkOption {
|
||||
type = types.str;
|
||||
description = mdDoc ''
|
||||
The Redis server name.
|
||||
'';
|
||||
default = "pterodactis";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
services.redis.servers.${cfg.redisName} = {
|
||||
enable = true;
|
||||
port = 6379;
|
||||
};
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
user = cfg.user;
|
||||
virtualHosts."${cfg.nginxVhost}" = {
|
||||
root = "${cfg.dataDir}/public";
|
||||
extraConfig = ''
|
||||
index index.html index.htm index.php;
|
||||
'';
|
||||
locations = {
|
||||
"~ \\.php$" = {
|
||||
extraConfig = ''
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass unix:${config.services.phpfpm.pools.pterodactyl.socket};
|
||||
include ${pkgs.nginx}/conf/fastcgi_params;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param PHP_VALUE "upload_max_filesize = 100M \n post_max_size=100M";
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param HTTP_PROXY "";
|
||||
fastcgi_intercept_errors off;
|
||||
fastcgi_buffer_size 16k;
|
||||
fastcgi_buffers 4 16k;
|
||||
fastcgi_connect_timeout 300;
|
||||
fastcgi_send_timeout 300;
|
||||
fastcgi_read_timeout 300;
|
||||
'';
|
||||
};
|
||||
"/" = { tryFiles = "$uri $uri/ /index.php?$query_string"; };
|
||||
};
|
||||
};
|
||||
};
|
||||
services.phpfpm.pools.pterodactyl = {
|
||||
user = cfg.user;
|
||||
settings = {
|
||||
"listen.owner" = config.services.nginx.user;
|
||||
"pm" = "dynamic";
|
||||
"pm.start_servers" = 4;
|
||||
"pm.min_spare_servers" = 4;
|
||||
"pm.max_spare_servers" = 16;
|
||||
"pm.max_children" = 64;
|
||||
"pm.max_requests" = 256;
|
||||
|
||||
"clear_env" = false;
|
||||
"catch_workers_output" = true;
|
||||
"decorate_workers_output" = false;
|
||||
"php_admin_value[error_log]" = "stderr";
|
||||
"php_admin_flag[daemonize]" = "false";
|
||||
};
|
||||
};
|
||||
users.users.${cfg.user} = {
|
||||
isSystemUser = true;
|
||||
createHome = true;
|
||||
home = cfg.dataDir;
|
||||
group = cfg.user;
|
||||
};
|
||||
users.groups.${cfg.user} = { };
|
||||
|
||||
systemd.services.pteroq = {
|
||||
enable = true;
|
||||
description = "Pterodactyl Queue Worker";
|
||||
after = [ "redis-${cfg.redisName}.service" ];
|
||||
unitConfig = { StartLimitInterval = 180; };
|
||||
serviceConfig = {
|
||||
User = cfg.user;
|
||||
Group = cfg.user;
|
||||
Restart = "always";
|
||||
ExecStart =
|
||||
"${pterodactlyPhp83}/bin/php ${cfg.dataDir}/artisan queue:work --queue=high,standard,low --sleep=3 --tries=3";
|
||||
StartLimitBurst = 30;
|
||||
RestartSec = "5s";
|
||||
};
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
};
|
||||
|
||||
environment.systemPackages = [
|
||||
pterodactlyPhp83
|
||||
# composer
|
||||
(pkgs.php83Packages.composer.override { php = pterodactlyPhp83; })
|
||||
];
|
||||
};
|
||||
}
|
53
modules/wings.nix
Normal file
53
modules/wings.nix
Normal file
|
@ -0,0 +1,53 @@
|
|||
{ lib, config, pkgs, ... }:
|
||||
with lib;
|
||||
let
|
||||
configuration = ''
|
||||
# managed by NixOS
|
||||
'' + "${config.services.wings.configuration}";
|
||||
in {
|
||||
options.services.wings = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
};
|
||||
configuration = mkOption {
|
||||
type = types.str;
|
||||
default = null;
|
||||
};
|
||||
pkg = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.pterodactyl-wings;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf config.services.wings.enable {
|
||||
assertions = [{
|
||||
assertion = config.services.wings.configuration != null;
|
||||
message = "wings is enabled, configuration must be set.";
|
||||
}];
|
||||
|
||||
virtualisation.docker.enable = true;
|
||||
environment.etc."pterodactyl/config.yml".text = configuration;
|
||||
environment.systemPackages = [ config.services.wings.pkg ];
|
||||
systemd.services.wings = {
|
||||
enable = cfg.enable;
|
||||
description = "Pterodactyl Wings daemon";
|
||||
after = [ "docker.service" ];
|
||||
partOf = [ "docker.service" ];
|
||||
requires = [ "docker.service" ];
|
||||
startLimitIntervalSec = 180;
|
||||
startLimitBurst = 30;
|
||||
serviceConfig = {
|
||||
User = "root";
|
||||
WorkingDirectory = "/run/wings";
|
||||
LimitNOFILE = 4096;
|
||||
PIDFile = "/var/run/wings/daemon.pid";
|
||||
ExecStart =
|
||||
"/bin/sh -c '/usr/bin/env mkdir /run/wings; /usr/bin/env cat /etc/pterodactyl/config.yml > /run/wings/config.yml; ${config.services.wings.pkg}/bin/wings --config /run/wings/config.yml'";
|
||||
Restart = "on-failure";
|
||||
RestartSec = "5s";
|
||||
};
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue