forked from pterodactyl/panel
-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
flake.nix
137 lines (117 loc) · 3.52 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
{
description = "Pterodactyl Panel";
inputs = {
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
systems.url = "github:nix-systems/default";
};
outputs = {self, ...} @ inputs:
inputs.flake-parts.lib.mkFlake {inherit inputs;} {
systems = import inputs.systems;
perSystem = {
pkgs,
system,
...
}: let
php = pkgs.php; # PHP 8.2
phpWithExtensions = php.buildEnv {
extensions = {
enabled,
all,
}:
enabled
++ (with all; [
redis
xdebug
]);
extraConfig = ''
xdebug.mode=debug
'';
};
composer = php.packages.composer.override {php = phpWithExtensions;};
in {
# Initialize pkgs with our overlays
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
};
devShells.default = pkgs.mkShellNoCC {
buildInputs = with pkgs; [
composer
nodejs_18
nodePackages.pnpm
phpWithExtensions
];
shellHook = ''
PATH="$PATH:${pkgs.docker-compose}/libexec/docker/cli-plugins"
'';
};
packages.development = pkgs.dockerTools.buildImage {
name = "pterodactyl/development";
tag = "panel";
copyToRoot = pkgs.buildEnv (let
caddyfile = pkgs.writeText "Caddyfile" ''
:80 {
root * /var/www/html/public/
file_server
header {
-Server
-X-Powered-By
Referrer-Policy "same-origin"
X-Frame-Options "deny"
X-XSS-Protection "1; mode=block"
X-Content-Type-Options "nosniff"
}
encode gzip zstd
php_fastcgi localhost:9000 {
trusted_proxies private_ranges
}
try_files {path} {path}/ /index.php?{query}
}
'';
phpfpmConf = pkgs.writeText "php-fpm.conf" ''
[global]
error_log = /dev/stderr
daemonize = no
[www]
user = nobody
group = nobody
listen = 0.0.0.0:9000
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 = no
catch_workers_output = yes
decorate_workers_output = no
'';
in {
name = "image-root";
paths = with pkgs; [
(pkgs.runCommand "configs" {} ''
mkdir -p "$out"/etc/caddy
ln -s ${caddyfile} "$out"/etc/caddy/Caddyfile
ln -s ${phpfpmConf} "$out"/etc/php-fpm.conf
'')
bash
dockerTools.caCertificates
dockerTools.fakeNss
caddy
composer
coreutils
mysql80
nodejs_18
nodePackages.pnpm
nodePackages.yarn
phpWithExtensions
];
pathsToLink = ["/bin" "/etc"];
});
};
};
};
}