forked from shopware/shopware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
devenv.nix
158 lines (136 loc) · 4.76 KB
/
devenv.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
{ pkgs, lib, config, ... }:
let
pcov = config.languages.php.package.buildEnv {
extensions = { all, enabled }: with all; (builtins.filter (e: e.extensionName != "blackfire" && e.extensionName != "xdebug") enabled) ++ [config.languages.php.package.extensions.pcov];
extraConfig = config.languages.php.ini;
};
in {
packages = [
pkgs.gnupatch
pkgs.nodePackages_latest.yalc
pkgs.gnused
pkgs.symfony-cli
pkgs.deno
pkgs.jq
pkgs.ludtwig
( pkgs.writeShellScriptBin "php-pcov" ''
export PHP_INI_SCAN_DIR=''${PHP_INI_SCAN_DIR-'${pcov}/lib'}
exec -a "$0" "${pcov}/bin/.php-wrapped" "$@"
'')
];
# Fix .env loading
process.implementation = lib.mkDefault "honcho";
dotenv.disableHint = true;
languages.javascript = {
enable = lib.mkDefault true;
package = lib.mkDefault pkgs.nodejs_20;
};
languages.php = {
enable = lib.mkDefault true;
version = lib.mkDefault "8.2";
extensions = [ "grpc" ];
ini = ''
memory_limit = 2G
realpath_cache_ttl = 3600
session.gc_probability = 0
${lib.optionalString config.services.redis.enable ''
session.save_handler = redis
session.save_path = "tcp://127.0.0.1:${toString config.services.redis.port}/0"
''}
display_errors = On
error_reporting = E_ALL
assert.active = 0
opcache.memory_consumption = 256M
opcache.interned_strings_buffer = 20
zend.assertions = 0
short_open_tag = 0
zend.detect_unicode = 0
realpath_cache_ttl = 3600
post_max_size = 32M
upload_max_filesize = 32M
'';
fpm.pools.web = lib.mkDefault {
settings = {
"clear_env" = "no";
"pm" = "dynamic";
"pm.max_children" = 10;
"pm.start_servers" = 2;
"pm.min_spare_servers" = 1;
"pm.max_spare_servers" = 10;
};
};
};
services.caddy = {
enable = lib.mkDefault true;
virtualHosts.":8000" = lib.mkDefault {
extraConfig = lib.mkDefault ''
@default {
not path /theme/* /media/* /thumbnail/* /bundles/* /css/* /fonts/* /js/* /sitemap/*
}
encode zstd gzip
root * public
php_fastcgi @default unix/${config.languages.php.fpm.pools.web.socket} {
trusted_proxies private_ranges
}
file_server
encode
encode zstd gzip
'';
};
};
services.mysql = {
enable = true;
package = pkgs.mysql80;
initialDatabases = lib.mkDefault [{ name = "shopware"; }];
ensureUsers = lib.mkDefault [
{
name = "shopware";
password = "shopware";
ensurePermissions = {
"shopware.*" = "ALL PRIVILEGES";
"shopware_test.*" = "ALL PRIVILEGES";
};
}
];
settings = {
mysqld = {
group_concat_max_len = 320000;
log_bin_trust_function_creators = 1;
sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION";
};
};
};
services.redis.enable = lib.mkDefault true;
# WSL2 fix locale
services.redis.extraConfig = "locale-collate C";
services.adminer.enable = lib.mkDefault true;
services.adminer.package = lib.mkDefault pkgs.adminerevo;
services.adminer.listen = lib.mkDefault "127.0.0.1:9080";
services.mailpit.enable = lib.mkDefault true;
# services.opensearch.enable = true;
# services.rabbitmq.enable = true;
# services.rabbitmq.managementPlugin.enable = true;
# Environment variables
env.APP_URL = lib.mkDefault "http://localhost:8000";
env.APP_SECRET = lib.mkDefault "def00000bb5acb32b54ff8ee130270586eec0e878f7337dc7a837acc31d3ff00f93a56b595448b4b29664847dd51991b3314ff65aeeeb761a133b0ec0e070433bff08e48";
env.DATABASE_URL = lib.mkDefault "mysql://root@localhost:3306/shopware";
env.MAILER_DSN = lib.mkDefault "smtp://localhost:1025";
# Elasticsearch
env.OPENSEARCH_URL = lib.mkDefault "http://localhost:9200";
env.ADMIN_OPENSEARCH_URL = lib.mkDefault "http://localhost:9200";
# General cypress
env.CYPRESS_baseUrl = lib.mkDefault "http://localhost:8000";
# Installer/Updater testing
env.INSTALL_URL = lib.mkDefault "http://localhost:8050";
env.CYPRESS_dbHost = lib.mkDefault "localhost";
env.CYPRESS_dbUser = lib.mkDefault "shopware";
env.CYPRESS_dbPassword = lib.mkDefault "shopware";
env.CYPRESS_dbName = lib.mkDefault "shopware";
# Disable session variables setting in kernel
env.SQL_SET_DEFAULT_SESSION_VARIABLES = lib.mkDefault "0";
scripts.build-updater.exec = ''
${pkgs.phpPackages.box}/bin/box compile -d src/WebInstaller
mv src/WebInstaller/shopware-installer.phar.php shop/public/shopware-installer.phar.php
'';
scripts.watch-updater.exec = "${pkgs.watchexec}/bin/watchexec -i src/WebInstaller/shopware-installer.phar.php -eyaml,php,js build-updater";
}