From 36c15877a9346adee3f153823e0bd49c7657817d Mon Sep 17 00:00:00 2001 From: Tobias Matthaiou <225997+TumTum@users.noreply.github.com> Date: Thu, 2 Mar 2023 15:44:38 +0100 Subject: [PATCH 01/24] Fix to send caddy into the http to run the ./bin/watch-*.sh [issue #17] --- devenv.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/devenv.nix b/devenv.nix index 9e763db..45b6c42 100644 --- a/devenv.nix +++ b/devenv.nix @@ -36,6 +36,7 @@ let phpVersion = if builtins.hasAttr "PHP_VERSION" config.env then config.env.PHP_VERSION else cfg.phpVersion; package = inputs.phps.packages.${builtins.currentSystem}.${phpVersion}; + caddyHttps = if cfg.enableHttps then "https" else "http"; phpPackage = package.buildEnv { extensions = { all, enabled }: with all; enabled @@ -192,6 +193,12 @@ in { example = [ "mailparse" ]; }; + enableHttps = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Enable HTTPS. If this is active, the scripts ./bin/watch-*.sh will not work."; + }; + additionalVhostConfig = lib.mkOption { type = lib.types.str; default = ""; @@ -293,7 +300,7 @@ in { auto_https disable_redirects } ''; - virtualHosts."127.0.0.1:8000" = lib.mkDefault { + virtualHosts."${caddyHttps}://127.0.0.1:8000" = lib.mkDefault { serverAliases = cfg.additionalServerAlias; extraConfig = lib.strings.concatStrings [ '' @@ -306,7 +313,9 @@ in { expression header_regexp('xdebug', 'Cookie', 'XDEBUG_SESSION') || query({'XDEBUG_SESSION': '*'}) } + ${lib.strings.optionalString cfg.enableHttps '' tls internal + '' } root * ${cfg.documentRoot} From 1dedc5cbf08aecb53dae03218838f68ffe5658d4 Mon Sep 17 00:00:00 2001 From: Jochen Manz Date: Tue, 28 Mar 2023 09:26:10 +0200 Subject: [PATCH 02/24] [NOTICKET] restructure files and wip caddy certificate handling --- .gitignore | 1 + devenv.lock | 30 ++-- devenv.nix | 333 ++------------------------------------- examples/sw5/devenv.yaml | 4 +- modules/caddy.nix | 98 ++++++++++++ modules/mysql.nix | 42 +++++ modules/php.nix | 91 +++++++++++ modules/scripts.nix | 142 +++++++++++++++++ 8 files changed, 403 insertions(+), 338 deletions(-) create mode 100644 modules/caddy.nix create mode 100644 modules/mysql.nix create mode 100644 modules/php.nix create mode 100644 modules/scripts.nix diff --git a/.gitignore b/.gitignore index 6506a66..6724501 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ # Devenv .devenv* +.direnv devenv.local.nix diff --git a/devenv.lock b/devenv.lock index ea072d0..67fcbe5 100644 --- a/devenv.lock +++ b/devenv.lock @@ -3,11 +3,11 @@ "devenv": { "locked": { "dir": "src/modules", - "lastModified": 1677721981, - "narHash": "sha256-vIXNwm98F2u5z9CLfWP72MJxaseVDBqnGhQGAFyxbLA=", + "lastModified": 1679514134, + "narHash": "sha256-x6wKyiOuJJW2phDbCpmSYjRlCe4Yva4r2nkqc7aNFsI=", "owner": "cachix", "repo": "devenv", - "rev": "8454b85158482d93dcc3f20b77fef5272313d127", + "rev": "a02418232d775e99ca349e1c8f71400aa1dd903c", "type": "github" }, "original": { @@ -103,11 +103,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1673800717, - "narHash": "sha256-SFHraUqLSu5cC6IxTprex/nTsI81ZQAtDvlBvGDWfnA=", + "lastModified": 1678872516, + "narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2f9fd351ec37f5d479556cd48be4ca340da59b8f", + "rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8", "type": "github" }, "original": { @@ -126,11 +126,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1677386056, - "narHash": "sha256-7zjqCeKW7YWjqR6EsUOqd2JzyCioYGVbbqmTgHTytBs=", + "lastModified": 1679508805, + "narHash": "sha256-WVByX40SpuNeOsELMoaqkhlj3VtJXv6oavv70uAJLvs=", "owner": "fossar", "repo": "nix-phps", - "rev": "98c16af0f9c329de8d62ef4817a5356c7685fffb", + "rev": "89a661b5450afa0633235347cc19b64e859d1cc7", "type": "github" }, "original": { @@ -150,11 +150,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1677722096, - "narHash": "sha256-7mjVMvCs9InnrRybBfr5ohqcOz+pyEX8m22C1XsDilg=", + "lastModified": 1678976941, + "narHash": "sha256-skNr08frCwN9NO+7I77MjOHHAw+L410/37JknNld+W4=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "61a3511668891c68ebd19d40122150b98dc2fe3b", + "rev": "32b1dbedfd77892a6e375737ef04d8efba634e9e", "type": "github" }, "original": { @@ -173,11 +173,11 @@ }, "utils": { "locked": { - "lastModified": 1676283394, - "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "lastModified": 1678901627, + "narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=", "owner": "numtide", "repo": "flake-utils", - "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6", "type": "github" }, "original": { diff --git a/devenv.nix b/devenv.nix index 9e763db..da822d0 100644 --- a/devenv.nix +++ b/devenv.nix @@ -3,157 +3,14 @@ let cfg = config.kellerkinder; - phpConfig = lib.strings.concatStrings [ - '' - memory_limit = 2G - pdo_mysql.default_socket = ''${MYSQL_UNIX_PORT} - mysqli.default_socket = ''${MYSQL_UNIX_PORT} - blackfire.agent_socket = "${config.services.blackfire.socket}"; - realpath_cache_ttl = 3600 - session.gc_probability = 0 - display_errors = On - display_startup_errors = true - error_reporting = E_ALL - html_errors = true - assert.active = 0 - zend.detect_unicode = 0 - opcache.memory_consumption = 256M - opcache.interned_strings_buffer = 20 - opcache.enable_file_override = 1 - opcache.enable_cli = 1 - opcache.enabled = 1 - zend.assertions = 0 - short_open_tag = 0 - xdebug.mode = "debug" - xdebug.start_with_request = "trigger" - xdebug.discover_client_host = 1 - xdebug.var_display_max_depth = -1 - xdebug.var_display_max_data = -1 - xdebug.var_display_max_children = -1 - '' - cfg.additionalPhpConfig - ]; - - phpVersion = if builtins.hasAttr "PHP_VERSION" config.env then config.env.PHP_VERSION else cfg.phpVersion; - package = inputs.phps.packages.${builtins.currentSystem}.${phpVersion}; - - phpPackage = package.buildEnv { - extensions = { all, enabled }: with all; enabled - ++ (lib.optional config.services.redis.enable redis) - ++ (lib.optional config.services.blackfire.enable blackfire) - ++ (lib.optional config.services.rabbitmq.enable amqp) - ++ lib.attrsets.attrValues (lib.attrsets.getAttrs cfg.additionalPhpExtensions package.extensions); - extraConfig = phpConfig; - }; - - phpXdebug = package.buildEnv { - extensions = { all, enabled }: with all; enabled - ++ [ xdebug ] - ++ (lib.optional config.services.redis.enable redis) - ++ (lib.optional config.services.rabbitmq.enable amqp) - ++ lib.attrsets.attrValues (lib.attrsets.getAttrs cfg.additionalPhpExtensions package.extensions); - extraConfig = phpConfig; - }; - - entryScript = pkgs.writeScript "entryScript" '' - set -euo pipefail - - if [ ! -f $DEVENV_PROFILE/bin/mysqladmin ]; then - echo -e "mysqladmin missing, skips further entryscript processing" - ${pkgs.coreutils}/bin/sleep infinity - fi - - while ! $DEVENV_PROFILE/bin/mysqladmin ping --silent; do - ${pkgs.coreutils}/bin/sleep 1 - done - - while ! [[ $($DEVENV_PROFILE/bin/mysql shopware -s -N -e 'SHOW DATABASES LIKE "shopware";') ]] ; do - ${pkgs.coreutils}/bin/sleep 1 - done - - TABLE=$(mysql shopware -s -N -e 'SHOW TABLES LIKE "system_config";') - - if [[ $TABLE == "" ]]; then - echo "Table system_config is missing. Run >updateSystemConfig< manually to ensure the dev status of your setup!" - ${pkgs.coreutils}/bin/sleep infinity - fi - - ${scriptUpdateConfig} - - echo -e "Startup completed" - ${pkgs.coreutils}/bin/sleep infinity - ''; - - systemConfigEntries = lib.mapAttrsToList (name: value: { inherit name value; }) cfg.systemConfig; - - scriptUpdateConfig = pkgs.writeScript "scriptUpdateConfig" '' - VENDOR=${config.env.DEVENV_ROOT}/vendor/autoload.php - CONSOLE=${config.env.DEVENV_ROOT}/bin/console - - echo "Updating system config" - - if [ ! -f "$VENDOR" ] || [ ! -f "$CONSOLE" ]; then - echo "Vendor folder or console not found. Please run composer install." - exit 1 - fi - - # additional config - ${lib.concatMapStrings ({ name, value }: '' - $CONSOLE system:config:set ${name} ${value} || exit 1 - echo "System config ${name} set to ${value}" - '') systemConfigEntries} - - # default config - $CONSOLE system:config:set core.mailerSettings.emailAgent "" || exit 1 - echo "System config core.mailerSettings.emailAgent set to '''" - ''; - - importDbHelper = pkgs.writeScript "importDbHelper" '' - if [[ "$1" == "" ]]; then - echo "Please set devenv configuration for kellerkinder.importDatabaseDumps" - exit - fi - - if ! $DEVENV_PROFILE/bin/mysqladmin ping > /dev/null 2>&1; then - echo "MySQL server is dead or has gone away! devenv up?" - exit - fi - - TARGETFOLDER="${config.env.DEVENV_STATE}/importdb" - - rm -rf "$TARGETFOLDER" - set -e - - if [[ "$1" == *.sql ]]; then - ${pkgs.curl}/bin/curl -s --create-dirs "$1" --output "$TARGETFOLDER/latest.sql" - elif [[ "$1" == *.gz ]]; then - ${pkgs.curl}/bin/curl -s --create-dirs "$1" --output "$TARGETFOLDER/latest.sql.gz" - ${pkgs.gzip}/bin/gunzip -q -c "$TARGETFOLDER/latest.sql.gz" > "$TARGETFOLDER/dump.sql" - elif [[ "$1" == *.zip ]]; then - ${pkgs.curl}/bin/curl -s --create-dirs "$1" --output "$TARGETFOLDER/latest.sql.zip" - ${pkgs.unzip}/bin/unzip -qq -j -o "$TARGETFOLDER/latest.sql.zip" '*.sql' -d "$TARGETFOLDER" - else - echo "Unsupported file type for file at $1" - exit - fi - - rm -f "$TARGETFOLDER/latest.sql.*" - - SQL_FILE=$(find "$TARGETFOLDER" -name "*.sql" | head -n 1) - - if [[ "$SQL_FILE" == "" ]]; then - echo "No SQL file found" - exit - fi - - LANG=C LC_CTYPE=C LC_ALL=C ${pkgs.gnused}/bin/sed -i -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' "$SQL_FILE" - LANG=C LC_CTYPE=C LC_ALL=C ${pkgs.gnused}/bin/sed -i 's/NO_AUTO_CREATE_USER//' "$SQL_FILE" - - $DEVENV_PROFILE/bin/mysql shopware -f < "$SQL_FILE" - - echo "Import $1 finished!" - ''; + listEntries = path: + map (name: path + "/${name}") (builtins.attrNames (builtins.readDir path)); in { + imports = [ + (lib.mkRenamedOptionModule [ "kellerkinder" "additionalServerAlias" ] [ "kellerkinder" "domains" ]) + (lib.mkRenamedOptionModule [ "kellerkinder" "fallbackRedirectMediaUrl" ] [ "kellerkinder" "fallbackMediaUrl" ]) + ] ++ (listEntries ./modules); + options.kellerkinder = { enable = lib.mkOption { type = lib.types.bool; @@ -198,9 +55,9 @@ in { description = "Additional vhost configuration"; }; - additionalServerAlias = lib.mkOption { + domains = lib.mkOption { type = lib.types.listOf lib.types.str; - description = "Additional server alias"; + description = "Domains to be used for the vhost"; default = [ ]; example = [ "example.com" ]; }; @@ -239,7 +96,7 @@ in { description = ''Sets the matcher paths to be "ignored" by caddy''; }; - fallbackRedirectMediaUrl = lib.mkOption { + fallbackMediaUrl = lib.mkOption { type = lib.types.str; default = ""; description = ''Fallback redirect URL for media not found on local storage. Best for CDN purposes without downloading them.''; @@ -247,7 +104,7 @@ in { }; config = lib.mkIf cfg.enable { - packages = [ + packages = lib.mkDefault [ pkgs.jq pkgs.gnupatch ]; @@ -257,131 +114,6 @@ in { package = lib.mkDefault pkgs.nodejs-16_x; }; - languages.php = { - enable = lib.mkDefault true; - package = lib.mkDefault phpPackage; - - fpm.pools.web = { - settings = { - "clear_env" = "no"; - "pm" = "dynamic"; - "pm.max_children" = 10; - "pm.start_servers" = 2; - "pm.min_spare_servers" = 1; - "pm.max_spare_servers" = 10; - }; - }; - fpm.pools.web.phpPackage = lib.mkDefault phpPackage; - - fpm.pools.xdebug = { - settings = { - "clear_env" = "no"; - "pm" = "dynamic"; - "pm.max_children" = 10; - "pm.start_servers" = 2; - "pm.min_spare_servers" = 1; - "pm.max_spare_servers" = 10; - }; - }; - fpm.pools.xdebug.phpPackage = lib.mkDefault phpXdebug; - }; - - services.caddy = { - enable = lib.mkDefault true; - config = '' - { - auto_https disable_redirects - } - ''; - virtualHosts."127.0.0.1:8000" = lib.mkDefault { - serverAliases = cfg.additionalServerAlias; - extraConfig = lib.strings.concatStrings [ - '' - @default { - not path ${cfg.staticFilePaths} - not expression header_regexp('xdebug', 'Cookie', 'XDEBUG_SESSION') || query({'XDEBUG_SESSION': '*'}) - } - @debugger { - not path ${cfg.staticFilePaths} - expression header_regexp('xdebug', 'Cookie', 'XDEBUG_SESSION') || query({'XDEBUG_SESSION': '*'}) - } - - tls internal - - root * ${cfg.documentRoot} - - encode zstd gzip - - handle /media/* { - ${lib.strings.optionalString (cfg.fallbackRedirectMediaUrl != "") '' - @notStatic not file - redir @notStatic ${lib.strings.removeSuffix "/" cfg.fallbackRedirectMediaUrl}{path} - ''} - file_server - } - - handle_errors { - respond "{err.status_code} {err.status_text}" - } - - handle { - php_fastcgi @default unix/${config.languages.php.fpm.pools.web.socket} { - trusted_proxies private_ranges - } - - php_fastcgi @debugger unix/${config.languages.php.fpm.pools.xdebug.socket} { - trusted_proxies private_ranges - } - - file_server - } - - log { - output stderr - format console - level ERROR - } - '' - cfg.additionalVhostConfig - ]; - }; - }; - - services.mysql = { - enable = lib.mkDefault true; - initialDatabases = lib.mkDefault [{ name = "shopware"; }]; - ensureUsers = lib.mkDefault [{ - name = "shopware"; - password = "shopware"; - ensurePermissions = { "*.*" = "ALL PRIVILEGES"; }; - }]; - settings = { - mysqld = { - group_concat_max_len = 2048; - key_buffer_size = 16777216; - max_allowed_packet = 134217728; - sync_binlog = 0; - table_open_cache = 1024; - log_bin_trust_function_creators = 1; - }; - mysql = { - user = "shopware"; - password = "shopware"; - host = "127.0.0.1"; - }; - mysqldump = { - user = "shopware"; - password = "shopware"; - host = "127.0.0.1"; - }; - mysqladmin = { - user = "shopware"; - password = "shopware"; - host = "127.0.0.1"; - }; - }; - }; - services.redis.enable = lib.mkDefault true; services.adminer.enable = lib.mkDefault true; @@ -421,49 +153,8 @@ in { }) (lib.mkIf config.services.rabbitmq.enable { RABBITMQ_NODENAME = "rabbit@localhost"; # 127.0.0.1 can't be used as rabbitmq can't set short node name + MESSENGER_TRANSPORT_DSN = "amqp://guest:guest@localhost:5672/%2f"; }) ]; - - # Processes - processes.entryscript.exec = "${entryScript}"; - - # Config related scripts - scripts.updateSystemConfig.exec = '' - ${scriptUpdateConfig} - ''; - - # Symfony related scripts - scripts.cc.exec = '' - CONSOLE=${config.env.DEVENV_ROOT}/bin/console - - if test -f "$CONSOLE"; then - exec $CONSOLE cache:clear - fi - ''; - - scripts.uuid.exec = '' - ${pkgs.toybox}/bin/uuidgen | tr "[:upper:]" "[:lower:]" | sed 's/-//g' - ''; - - scripts.debug.exec = '' - XDEBUG_SESSION=1 ${phpXdebug}/bin/php "$@" - ''; - - scripts.importdb.exec = '' - echo "Are you sure you want to download SQL files and overwrite the existing database with their data (y/n)?" - read answer - - if [[ "$answer" != "y" ]]; then - echo "Alright, we will stop here." - exit - fi - - ${lib.concatMapStrings (dump: '' - echo "Importing ${dump}" - ${importDbHelper} ${dump} - '') cfg.importDatabaseDumps} - - ${scriptUpdateConfig} - ''; }; } diff --git a/examples/sw5/devenv.yaml b/examples/sw5/devenv.yaml index cd5b5c7..216a225 100644 --- a/examples/sw5/devenv.yaml +++ b/examples/sw5/devenv.yaml @@ -8,6 +8,6 @@ inputs: inputs: nixpkgs: follows: nixpkgs - imports: - - kellerkinder +imports: + - kellerkinder diff --git a/modules/caddy.nix b/modules/caddy.nix new file mode 100644 index 0000000..7a05aa1 --- /dev/null +++ b/modules/caddy.nix @@ -0,0 +1,98 @@ +{ pkgs, config, inputs, lib, ... }: + +let + cfg = config.kellerkinder; + + mappedHosts = lib.mapAttrsToList (name: value: { inherit name; }) cfg.domains; + + vhostDomains = cfg.domains ++ [ "127.0.0.1" ]; + + vhostConfig = lib.strings.concatStrings [ + '' + @default { + not path ${cfg.staticFilePaths} + not expression header_regexp('xdebug', 'Cookie', 'XDEBUG_SESSION') || query({'XDEBUG_SESSION': '*'}) + } + @debugger { + not path ${cfg.staticFilePaths} + expression header_regexp('xdebug', 'Cookie', 'XDEBUG_SESSION') || query({'XDEBUG_SESSION': '*'}) + } + + root * ${cfg.documentRoot} + + encode zstd gzip + + handle /media/* { + ${lib.strings.optionalString (cfg.fallbackMediaUrl != "") '' + @notStatic not file + redir @notStatic ${lib.strings.removeSuffix "/" cfg.fallbackMediaUrl}{path} + ''} + file_server + } + + handle_errors { + respond "{err.status_code} {err.status_text}" + } + + handle { + php_fastcgi @default unix/${config.languages.php.fpm.pools.web.socket} { + trusted_proxies private_ranges + index shopware.php index.php + } + + php_fastcgi @debugger unix/${config.languages.php.fpm.pools.xdebug.socket} { + trusted_proxies private_ranges + index shopware.php index.php + } + + file_server + } + + log { + output stderr + format console + level ERROR + } + '' + cfg.additionalVhostConfig + ]; + + vhostConfigSSL = lib.strings.concatStrings [ + '' + tls ${config.env.DEVENV_STATE}/mkcert/%DOMAIN%.pem ${config.env.DEVENV_STATE}/mkcert/%DOMAIN%-key.pem + '' + vhostConfig + ]; +in { + config = lib.mkIf cfg.enable { + hosts = { + "example.com" = "127.0.0.1"; + }; + + certificates = [ "127.0.0.1" ] ++ cfg.domains; + + services.caddy = { + enable = lib.mkDefault true; + virtualHosts = lib.mkMerge [ + (lib.concatMapStrings + (domain: { + "${domain}:80" = lib.mkDefault { + enable = true; + extraConfig = vhostConfig; + }; + }) + vhostDomains + ) + (lib.concatMapStrings + (domain: { + "${domain}:443" = lib.mkDefault { + enable = true; + extraConfig = lib.replaceStrings [ "%DOMAIN%" domain ] vhostConfigSSL; + }; + }) + vhostDomains + ) + ]; + }; + }; +} diff --git a/modules/mysql.nix b/modules/mysql.nix new file mode 100644 index 0000000..570eea9 --- /dev/null +++ b/modules/mysql.nix @@ -0,0 +1,42 @@ +{ pkgs, config, inputs, lib, ... }: + +let + cfg = config.kellerkinder; +in { + config = lib.mkIf cfg.enable { + services.mysql = { + enable = lib.mkDefault true; + initialDatabases = lib.mkDefault [{ name = "shopware"; }]; + ensureUsers = lib.mkDefault [{ + name = "shopware"; + password = "shopware"; + ensurePermissions = { "*.*" = "ALL PRIVILEGES"; }; + }]; + settings = { + mysqld = { + group_concat_max_len = 2048; + key_buffer_size = 16777216; + max_allowed_packet = 134217728; + sync_binlog = 0; + table_open_cache = 1024; + log_bin_trust_function_creators = 1; + }; + mysql = { + user = "shopware"; + password = "shopware"; + host = "127.0.0.1"; + }; + mysqldump = { + user = "shopware"; + password = "shopware"; + host = "127.0.0.1"; + }; + mysqladmin = { + user = "shopware"; + password = "shopware"; + host = "127.0.0.1"; + }; + }; + }; + }; +} diff --git a/modules/php.nix b/modules/php.nix new file mode 100644 index 0000000..3037e7e --- /dev/null +++ b/modules/php.nix @@ -0,0 +1,91 @@ +{ pkgs, config, inputs, lib, ... }: + +let + cfg = config.kellerkinder; + + phpConfig = lib.strings.concatStrings [ + '' + memory_limit = 2G + pdo_mysql.default_socket = ''${MYSQL_UNIX_PORT} + mysqli.default_socket = ''${MYSQL_UNIX_PORT} + blackfire.agent_socket = "${config.services.blackfire.socket}"; + realpath_cache_ttl = 3600 + session.gc_probability = 0 + display_errors = On + display_startup_errors = true + error_reporting = E_ALL + html_errors = true + assert.active = 0 + zend.detect_unicode = 0 + opcache.memory_consumption = 256M + opcache.interned_strings_buffer = 20 + opcache.enable_cli = 1 + opcache.enabled = 1 + zend.assertions = 0 + short_open_tag = 0 + xdebug.mode = "debug" + xdebug.start_with_request = "trigger" + xdebug.discover_client_host = 1 + xdebug.var_display_max_depth = -1 + xdebug.var_display_max_data = -1 + xdebug.var_display_max_children = -1 + '' + cfg.additionalPhpConfig + ]; + + phpVersion = if builtins.hasAttr "PHP_VERSION" config.env then config.env.PHP_VERSION else cfg.phpVersion; + package = inputs.phps.packages.${builtins.currentSystem}.${phpVersion}; + + phpPackage = package.buildEnv { + extensions = { all, enabled }: with all; enabled + ++ (lib.optional config.services.redis.enable redis) + ++ (lib.optional config.services.blackfire.enable blackfire) + ++ (lib.optional config.services.rabbitmq.enable amqp) + ++ lib.attrsets.attrValues (lib.attrsets.getAttrs cfg.additionalPhpExtensions package.extensions); + extraConfig = phpConfig; + }; + + phpXdebug = package.buildEnv { + extensions = { all, enabled }: with all; enabled + ++ [ xdebug ] + ++ (lib.optional config.services.redis.enable redis) + ++ (lib.optional config.services.rabbitmq.enable amqp) + ++ lib.attrsets.attrValues (lib.attrsets.getAttrs cfg.additionalPhpExtensions package.extensions); + extraConfig = phpConfig; + }; +in { + config = lib.mkIf cfg.enable { + languages.php = { + enable = lib.mkDefault true; + package = lib.mkDefault phpPackage; + + fpm.pools.web = { + settings = { + "clear_env" = "no"; + "pm" = "dynamic"; + "pm.max_children" = 10; + "pm.start_servers" = 2; + "pm.min_spare_servers" = 1; + "pm.max_spare_servers" = 10; + }; + }; + fpm.pools.web.phpPackage = lib.mkDefault phpPackage; + + fpm.pools.xdebug = { + settings = { + "clear_env" = "no"; + "pm" = "dynamic"; + "pm.max_children" = 10; + "pm.start_servers" = 2; + "pm.min_spare_servers" = 1; + "pm.max_spare_servers" = 10; + }; + }; + fpm.pools.xdebug.phpPackage = lib.mkDefault phpXdebug; + }; + + scripts.debug.exec = '' + XDEBUG_SESSION=1 ${phpXdebug}/bin/php "$@" + ''; + }; +} diff --git a/modules/scripts.nix b/modules/scripts.nix new file mode 100644 index 0000000..def1af6 --- /dev/null +++ b/modules/scripts.nix @@ -0,0 +1,142 @@ +{ pkgs, config, inputs, lib, ... }: + +let + cfg = config.kellerkinder; + + entryScript = pkgs.writeScript "entryScript" '' + set -euo pipefail + + if [ ! -f $DEVENV_PROFILE/bin/mysqladmin ]; then + echo -e "mysqladmin missing, skips further entryscript processing" + ${pkgs.coreutils}/bin/sleep infinity + fi + + while ! $DEVENV_PROFILE/bin/mysqladmin ping --silent; do + ${pkgs.coreutils}/bin/sleep 1 + done + + while ! [[ $($DEVENV_PROFILE/bin/mysql shopware -s -N -e 'SHOW DATABASES LIKE "shopware";') ]] ; do + ${pkgs.coreutils}/bin/sleep 1 + done + + TABLE=$(mysql shopware -s -N -e 'SHOW TABLES LIKE "system_config";') + + if [[ $TABLE == "" ]]; then + echo "Table system_config is missing. Run >updateSystemConfig< manually to ensure the dev status of your setup!" + ${pkgs.coreutils}/bin/sleep infinity + fi + + ${scriptUpdateConfig} + + echo -e "Startup completed" + ${pkgs.coreutils}/bin/sleep infinity + ''; + + systemConfigEntries = lib.mapAttrsToList (name: value: { inherit name value; }) cfg.systemConfig; + + scriptUpdateConfig = pkgs.writeScript "scriptUpdateConfig" '' + VENDOR=${config.env.DEVENV_ROOT}/vendor/autoload.php + CONSOLE=${config.env.DEVENV_ROOT}/bin/console + + echo "Updating system config" + + if [ ! -f "$VENDOR" ] || [ ! -f "$CONSOLE" ]; then + echo "Vendor folder or console not found. Please run composer install." + exit 1 + fi + + # additional config + ${lib.concatMapStrings ({ name, value }: '' + $CONSOLE system:config:set ${name} ${value} || exit 1 + echo "System config ${name} set to ${value}" + '') systemConfigEntries} + + # default config + $CONSOLE system:config:set core.mailerSettings.emailAgent "" || exit 1 + echo "System config core.mailerSettings.emailAgent set to '''" + ''; + + importDbHelper = pkgs.writeScript "importDbHelper" '' + if [[ "$1" == "" ]]; then + echo "Please set devenv configuration for kellerkinder.importDatabaseDumps" + exit + fi + + if ! $DEVENV_PROFILE/bin/mysqladmin ping > /dev/null 2>&1; then + echo "MySQL server is dead or has gone away! devenv up?" + exit + fi + + TARGETFOLDER="${config.env.DEVENV_STATE}/importdb" + + rm -rf "$TARGETFOLDER" + set -e + + if [[ "$1" == *.sql ]]; then + ${pkgs.curl}/bin/curl -s --create-dirs "$1" --output "$TARGETFOLDER/latest.sql" + elif [[ "$1" == *.gz ]]; then + ${pkgs.curl}/bin/curl -s --create-dirs "$1" --output "$TARGETFOLDER/latest.sql.gz" + ${pkgs.gzip}/bin/gunzip -q -c "$TARGETFOLDER/latest.sql.gz" > "$TARGETFOLDER/dump.sql" + elif [[ "$1" == *.zip ]]; then + ${pkgs.curl}/bin/curl -s --create-dirs "$1" --output "$TARGETFOLDER/latest.sql.zip" + ${pkgs.unzip}/bin/unzip -qq -j -o "$TARGETFOLDER/latest.sql.zip" '*.sql' -d "$TARGETFOLDER" + else + echo "Unsupported file type for file at $1" + exit + fi + + rm -f "$TARGETFOLDER/latest.sql.*" + + SQL_FILE=$(find "$TARGETFOLDER" -name "*.sql" | head -n 1) + + if [[ "$SQL_FILE" == "" ]]; then + echo "No SQL file found" + exit + fi + + LANG=C LC_CTYPE=C LC_ALL=C ${pkgs.gnused}/bin/sed -i -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' "$SQL_FILE" + LANG=C LC_CTYPE=C LC_ALL=C ${pkgs.gnused}/bin/sed -i 's/NO_AUTO_CREATE_USER//' "$SQL_FILE" + + $DEVENV_PROFILE/bin/mysql shopware -f < "$SQL_FILE" + + echo "Import $1 finished!" + ''; +in { + # Config related scripts + scripts.updateSystemConfig.exec = '' + ${scriptUpdateConfig} + ''; + + # Symfony related scripts + scripts.cc.exec = '' + CONSOLE=${config.env.DEVENV_ROOT}/bin/console + + if test -f "$CONSOLE"; then + exec $CONSOLE cache:clear + fi + ''; + + scripts.uuid.exec = '' + ${pkgs.toybox}/bin/uuidgen | tr "[:upper:]" "[:lower:]" | sed 's/-//g' + ''; + + scripts.importdb.exec = '' + echo "Are you sure you want to download SQL files and overwrite the existing database with their data (y/n)?" + read answer + + if [[ "$answer" != "y" ]]; then + echo "Alright, we will stop here." + exit + fi + + ${lib.concatMapStrings (dump: '' + echo "Importing ${dump}" + ${importDbHelper} ${dump} + '') cfg.importDatabaseDumps} + + ${scriptUpdateConfig} + ''; + + # Processes + processes.entryscript.exec = "${entryScript}"; +} From 5328115d827ce33f5f29a93acf2b48c7e7946af3 Mon Sep 17 00:00:00 2001 From: "a.wink" Date: Wed, 29 Mar 2023 10:29:01 +0200 Subject: [PATCH 03/24] fix: [noticket] Straightening the structural adjustments to restore the runnability - Deposit of the last changes from main-usage - Update docs according to changes --- devenv.nix | 11 ++-- docs/Options.md | 4 +- modules/caddy.nix | 134 ++++++++++++++++++---------------------------- modules/php.nix | 1 + 4 files changed, 62 insertions(+), 88 deletions(-) diff --git a/devenv.nix b/devenv.nix index 125872b..1486320 100644 --- a/devenv.nix +++ b/devenv.nix @@ -120,18 +120,18 @@ in { package = lib.mkDefault pkgs.nodejs-16_x; }; - services.redis.enable = lib.mkDefault true; - services.adminer.enable = lib.mkDefault true; services.adminer.listen = lib.mkDefault "127.0.0.1:8010"; - services.mailhog.enable = true; - services.elasticsearch.enable = cfg.enableElasticsearch; + services.mailhog.enable = true; + services.rabbitmq.enable = cfg.enableRabbitMq; services.rabbitmq.managementPlugin.enable = cfg.enableRabbitMq; + services.redis.enable = lib.mkDefault true; + # Environment variables env = lib.mkMerge [ (lib.mkIf cfg.enable { @@ -161,6 +161,9 @@ in { RABBITMQ_NODENAME = "rabbit@localhost"; # 127.0.0.1 can't be used as rabbitmq can't set short node name MESSENGER_TRANSPORT_DSN = "amqp://guest:guest@localhost:5672/%2f"; }) + (lib.mkIf config.services.redis.enable { + REDIS_DSN = "redis://127.0.0.1:6379"; + }) ]; }; } diff --git a/docs/Options.md b/docs/Options.md index 3638c60..59e6679 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -41,7 +41,7 @@ Define additional server aliases that are added to caddy. *_Example_* ``` -kellerkinder.additionalServerAlias = [ +kellerkinder.domains = [ "example.com" ]; ``` @@ -114,7 +114,7 @@ Fallback redirect URL for media not found on local storage. Best for CDN purpose *_Example_* ``` -kellerkinder.fallbackRedirectMediaUrl = "https://my-cool-cdn-in-public-staging.example-cdn.com"; +kellerkinder.fallbackMediaUrl = "https://my-cool-cdn-in-public-staging.example-cdn.com"; ``` # kellerkinder.additionalPackages diff --git a/modules/caddy.nix b/modules/caddy.nix index 7a05aa1..47cb15f 100644 --- a/modules/caddy.nix +++ b/modules/caddy.nix @@ -2,97 +2,67 @@ let cfg = config.kellerkinder; +in { + config = lib.mkIf cfg.enable { + services.caddy = { + enable = lib.mkDefault true; + config = '' + { + auto_https disable_redirects + } + ''; + virtualHosts."127.0.0.1:8000" = lib.mkDefault { + serverAliases = cfg.domains; + extraConfig = lib.strings.concatStrings [ + '' + @default { + not path ${cfg.staticFilePaths} + not expression header_regexp('xdebug', 'Cookie', 'XDEBUG_SESSION') || query({'XDEBUG_SESSION': '*'}) + } + @debugger { + not path ${cfg.staticFilePaths} + expression header_regexp('xdebug', 'Cookie', 'XDEBUG_SESSION') || query({'XDEBUG_SESSION': '*'}) + } - mappedHosts = lib.mapAttrsToList (name: value: { inherit name; }) cfg.domains; - - vhostDomains = cfg.domains ++ [ "127.0.0.1" ]; - - vhostConfig = lib.strings.concatStrings [ - '' - @default { - not path ${cfg.staticFilePaths} - not expression header_regexp('xdebug', 'Cookie', 'XDEBUG_SESSION') || query({'XDEBUG_SESSION': '*'}) - } - @debugger { - not path ${cfg.staticFilePaths} - expression header_regexp('xdebug', 'Cookie', 'XDEBUG_SESSION') || query({'XDEBUG_SESSION': '*'}) - } - - root * ${cfg.documentRoot} - - encode zstd gzip - - handle /media/* { - ${lib.strings.optionalString (cfg.fallbackMediaUrl != "") '' - @notStatic not file - redir @notStatic ${lib.strings.removeSuffix "/" cfg.fallbackMediaUrl}{path} - ''} - file_server - } + tls internal - handle_errors { - respond "{err.status_code} {err.status_text}" - } + root * ${cfg.documentRoot} - handle { - php_fastcgi @default unix/${config.languages.php.fpm.pools.web.socket} { - trusted_proxies private_ranges - index shopware.php index.php - } + encode zstd gzip - php_fastcgi @debugger unix/${config.languages.php.fpm.pools.xdebug.socket} { - trusted_proxies private_ranges - index shopware.php index.php - } + handle /media/* { + ${lib.strings.optionalString (cfg.fallbackRedirectMediaUrl != "") '' + @notStatic not file + redir @notStatic ${lib.strings.removeSuffix "/" cfg.fallbackRedirectMediaUrl}{path} + ''} + file_server + } - file_server - } + handle_errors { + respond "{err.status_code} {err.status_text}" + } - log { - output stderr - format console - level ERROR - } - '' - cfg.additionalVhostConfig - ]; + handle { + php_fastcgi @default unix/${config.languages.php.fpm.pools.web.socket} { + trusted_proxies private_ranges + } - vhostConfigSSL = lib.strings.concatStrings [ - '' - tls ${config.env.DEVENV_STATE}/mkcert/%DOMAIN%.pem ${config.env.DEVENV_STATE}/mkcert/%DOMAIN%-key.pem - '' - vhostConfig - ]; -in { - config = lib.mkIf cfg.enable { - hosts = { - "example.com" = "127.0.0.1"; - }; + php_fastcgi @debugger unix/${config.languages.php.fpm.pools.xdebug.socket} { + trusted_proxies private_ranges + } - certificates = [ "127.0.0.1" ] ++ cfg.domains; + file_server + } - services.caddy = { - enable = lib.mkDefault true; - virtualHosts = lib.mkMerge [ - (lib.concatMapStrings - (domain: { - "${domain}:80" = lib.mkDefault { - enable = true; - extraConfig = vhostConfig; - }; - }) - vhostDomains - ) - (lib.concatMapStrings - (domain: { - "${domain}:443" = lib.mkDefault { - enable = true; - extraConfig = lib.replaceStrings [ "%DOMAIN%" domain ] vhostConfigSSL; - }; - }) - vhostDomains - ) - ]; + log { + output stderr + format console + level ERROR + } + '' + cfg.additionalVhostConfig + ]; + }; }; }; } diff --git a/modules/php.nix b/modules/php.nix index 3037e7e..42101ab 100644 --- a/modules/php.nix +++ b/modules/php.nix @@ -19,6 +19,7 @@ let zend.detect_unicode = 0 opcache.memory_consumption = 256M opcache.interned_strings_buffer = 20 + opcache.enable_file_override = 1 opcache.enable_cli = 1 opcache.enabled = 1 zend.assertions = 0 From 2f899955eedb47dbf962331fa2131eeef9995a50 Mon Sep 17 00:00:00 2001 From: Jochen Manz Date: Mon, 8 May 2023 20:20:26 +0200 Subject: [PATCH 04/24] feat: restructure debug script --- modules/caddy.nix | 6 ++++-- modules/php.nix | 4 ---- modules/scripts.nix | 4 ++++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/caddy.nix b/modules/caddy.nix index 47cb15f..9780299 100644 --- a/modules/caddy.nix +++ b/modules/caddy.nix @@ -31,9 +31,9 @@ in { encode zstd gzip handle /media/* { - ${lib.strings.optionalString (cfg.fallbackRedirectMediaUrl != "") '' + ${lib.strings.optionalString (cfg.fallbackMediaUrl != "") '' @notStatic not file - redir @notStatic ${lib.strings.removeSuffix "/" cfg.fallbackRedirectMediaUrl}{path} + redir @notStatic ${lib.strings.removeSuffix "/" cfg.fallbackMediaUrl}{path} ''} file_server } @@ -45,10 +45,12 @@ in { handle { php_fastcgi @default unix/${config.languages.php.fpm.pools.web.socket} { trusted_proxies private_ranges + index shopware.php index.php } php_fastcgi @debugger unix/${config.languages.php.fpm.pools.xdebug.socket} { trusted_proxies private_ranges + index shopware.php index.php } file_server diff --git a/modules/php.nix b/modules/php.nix index 42101ab..9c0e4cd 100644 --- a/modules/php.nix +++ b/modules/php.nix @@ -84,9 +84,5 @@ in { }; fpm.pools.xdebug.phpPackage = lib.mkDefault phpXdebug; }; - - scripts.debug.exec = '' - XDEBUG_SESSION=1 ${phpXdebug}/bin/php "$@" - ''; }; } diff --git a/modules/scripts.nix b/modules/scripts.nix index def1af6..1b8600b 100644 --- a/modules/scripts.nix +++ b/modules/scripts.nix @@ -137,6 +137,10 @@ in { ${scriptUpdateConfig} ''; + scripts.debug.exec = '' + XDEBUG_SESSION=1 ${phpXdebug}/bin/php "$@" + ''; + # Processes processes.entryscript.exec = "${entryScript}"; } From f45d198792d490305036d5397856fad1995c3b68 Mon Sep 17 00:00:00 2001 From: Jochen Manz Date: Fri, 23 Jun 2023 20:33:10 +0200 Subject: [PATCH 05/24] [NOTICKET] update documentation --- docs/Options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Options.md b/docs/Options.md index bdd404b..f715195 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -133,7 +133,7 @@ Adjusts the defined matcher paths for caddy. You might want to adjust those to a kellerkinder.staticFilePaths = "myCustomFolder/*"; ``` -# kellerkinder.fallbackRedirectMediaUrl +# kellerkinder.fallbackMediaUrl Fallback redirect URL for media not found on local storage. Best for CDN purposes without downloading them. *_Example_* From e9824efe4ff24ee230e4d031ec8ad793441c8d5c Mon Sep 17 00:00:00 2001 From: Jochen Manz Date: Fri, 23 Jun 2023 20:34:30 +0200 Subject: [PATCH 06/24] [NOTICKET] update documentation --- docs/Home.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/Home.md b/docs/Home.md index 97074ef..887fe19 100644 --- a/docs/Home.md +++ b/docs/Home.md @@ -8,6 +8,7 @@ cachix use devenv ; cachix use fossar ; cachix use shopware Add the following files to the project `.gitignore` file: - `.devenv*` - `devenv.local.nix` +- `.direnv` # Options A full list of options can be found [here](Options.md). From c1589ee66e148f35e5f6f7a1551bda84d6664ebd Mon Sep 17 00:00:00 2001 From: Jochen Manz Date: Mon, 26 Jun 2023 11:59:23 +0200 Subject: [PATCH 07/24] [NOTICKET] implement additionalServerAlias handling with tls and http --- docs/Options.md | 2 +- modules/caddy.nix | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/Options.md b/docs/Options.md index f715195..24eb72b 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -41,7 +41,7 @@ Define additional server aliases that are added to caddy. *_Example_* ``` -kellerkinder.domains = [ +kellerkinder.additionalServerAlias = [ "example.com" ]; ``` diff --git a/modules/caddy.nix b/modules/caddy.nix index 27808a4..a2f952c 100644 --- a/modules/caddy.nix +++ b/modules/caddy.nix @@ -59,6 +59,17 @@ let '' vhostConfig ]; + + vhostDomains = cfg.additionalServerAlias ++ [ "127.0.0.1" ]; + + caddyHostConfig = (lib.mkMerge (lib.forEach vhostDomains (domain: { + "http://${toString domain}" = lib.mkDefault { + extraConfig = vhostConfig; + }; + "https://${toString domain}" = lib.mkDefault { + extraConfig = vhostConfigTsl; + }; + }))); in { config = lib.mkIf cfg.enable { services.caddy = { @@ -68,18 +79,7 @@ in { auto_https disable_redirects } ''; - virtualHosts = lib.mkMerge [ - (lib.mkIf cfg.enableTls { - "https://127.0.0.1" = lib.mkDefault { - extraConfig = vhostConfig; - }; - }) - { - "http://127.0.0.1" = lib.mkDefault { - extraConfig = vhostConfigTsl; - }; - } - ]; + virtualHosts = caddyHostConfig; }; }; } From 653f8b37f5d68f9ca54a92b50a59bcbbc623e5e9 Mon Sep 17 00:00:00 2001 From: Jochen Manz Date: Tue, 27 Jun 2023 12:41:47 +0200 Subject: [PATCH 08/24] [NOTICKET] remove unneeded mkDefault calls --- devenv.nix | 6 ------ docs/Options.md | 8 -------- modules/caddy.nix | 4 ++-- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/devenv.nix b/devenv.nix index bbe9aa2..83b269b 100644 --- a/devenv.nix +++ b/devenv.nix @@ -53,12 +53,6 @@ in { default = ""; }; - enableTls = lib.mkOption { - type = lib.types.bool; - default = true; - description = "Enables HTTPS/TLS in addition to HTTP."; - }; - additionalServerAlias = lib.mkOption { type = lib.types.listOf lib.types.str; description = "Additional server alias"; diff --git a/docs/Options.md b/docs/Options.md index 24eb72b..8844d1a 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -56,14 +56,6 @@ kellerkinder.additionalVhostConfig = '' ''; ``` -# kellerkinder.enableTls -Enables caddy to serve the default vhost with HTTPS/TLS in addition to HTTP. - -*_Example_* -``` -kellerkinder.enableTls = false; -``` - # kellerkinder.enableRabbitMq Enables the RabbitMQ message broker and amqp PHP extension. Can be used for the Symfony message queue. diff --git a/modules/caddy.nix b/modules/caddy.nix index a2f952c..e502ee3 100644 --- a/modules/caddy.nix +++ b/modules/caddy.nix @@ -63,10 +63,10 @@ let vhostDomains = cfg.additionalServerAlias ++ [ "127.0.0.1" ]; caddyHostConfig = (lib.mkMerge (lib.forEach vhostDomains (domain: { - "http://${toString domain}" = lib.mkDefault { + "http://${toString domain}" = { extraConfig = vhostConfig; }; - "https://${toString domain}" = lib.mkDefault { + "https://${toString domain}" = { extraConfig = vhostConfigTsl; }; }))); From 7216fb039336f103a5af17f366683516321380cb Mon Sep 17 00:00:00 2001 From: Jochen Manz Date: Tue, 27 Jun 2023 16:52:52 +0200 Subject: [PATCH 09/24] [NOTICKET] allow vhost port 8000 --- modules/caddy.nix | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/modules/caddy.nix b/modules/caddy.nix index e502ee3..b8cbeb4 100644 --- a/modules/caddy.nix +++ b/modules/caddy.nix @@ -53,7 +53,7 @@ let cfg.additionalVhostConfig ]; - vhostConfigTsl = lib.strings.concatStrings [ + vhostConfigTls = lib.strings.concatStrings [ '' tls internal '' @@ -62,14 +62,19 @@ let vhostDomains = cfg.additionalServerAlias ++ [ "127.0.0.1" ]; - caddyHostConfig = (lib.mkMerge (lib.forEach vhostDomains (domain: { - "http://${toString domain}" = { - extraConfig = vhostConfig; - }; - "https://${toString domain}" = { - extraConfig = vhostConfigTsl; - }; - }))); + caddyHostConfig = (lib.mkMerge + (lib.forEach vhostDomains (domain: { + "http://${toString domain}" = { + extraConfig = vhostConfig; + }; + "https://${toString domain}" = { + extraConfig = vhostConfigTls; + }; + "https://${toString domain}:8000" = { + extraConfig = vhostConfigTls; + }; + })) + ); in { config = lib.mkIf cfg.enable { services.caddy = { From 13d5ef5c96dce53a423cb18ce1078619710cb17b Mon Sep 17 00:00:00 2001 From: tinect Date: Mon, 10 Jul 2023 10:13:13 +0200 Subject: [PATCH 10/24] feat: use fallbackMediaUrl also for thumbnail, introduce option to define fallbackMediaPaths (#60) --- devenv.lock | 30 +++++++++++++++--------------- devenv.nix | 6 ++++++ docs/Options.md | 8 ++++++++ modules/caddy.nix | 6 +++++- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/devenv.lock b/devenv.lock index afc396d..24bc419 100644 --- a/devenv.lock +++ b/devenv.lock @@ -3,11 +3,11 @@ "devenv": { "locked": { "dir": "src/modules", - "lastModified": 1687378457, - "narHash": "sha256-EkRX4S60BGFlQuEYJegk/9aCODPdMV6XLI+2C2HTBEI=", + "lastModified": 1688925746, + "narHash": "sha256-Lora6gsuAdVeVeGj2nD4joxTu+jZsAwySlxY1XZVq8o=", "owner": "cachix", "repo": "devenv", - "rev": "c6ac4dbf501edafe0d6860e821b9e9fff0828921", + "rev": "b058455b37d2a1833eb71bebd3d2b2aa58ce70d7", "type": "github" }, "original": { @@ -90,11 +90,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1687412861, - "narHash": "sha256-Z/g0wbL68C+mSGerYS2quv9FXQ1RRP082cAC0Bh4vcs=", + "lastModified": 1688918189, + "narHash": "sha256-f8ZlJ67LgEUDnN7ZsAyd1/Fyby1VdOXWg4XY/irSGrQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e603dc5f061ca1d8a19b3ede6a8cf9c9fcba6cdc", + "rev": "408c0e8c15a1c9cf5c3226931b6f283c9867c484", "type": "github" }, "original": { @@ -129,11 +129,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1686690310, - "narHash": "sha256-Ps9srIZGWpfi1SfvJ3MaIG2bTPy+28eQVyTZ55A/3vE=", + "lastModified": 1688926492, + "narHash": "sha256-vOZ2IH/G0qcqyKg8jd50zB5zWpvgkiYH1ZwoUMnCi38=", "owner": "fossar", "repo": "nix-phps", - "rev": "0983b1d334561d6526a67a0919c6631e61e01b38", + "rev": "ed5fea0442ba23522fa95072d902e7a8fa31899d", "type": "github" }, "original": { @@ -153,11 +153,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1687251716, - "narHash": "sha256-+sFS41thsB5U+lY/dBYPSmU4AJ7nz/VdM1WD35fXVeM=", + "lastModified": 1688596063, + "narHash": "sha256-9t7RxBiKWHygsqXtiNATTJt4lim/oSYZV3RG8OjDDng=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "7807e1851d95828ed98491930d2d9e7ddbe65da4", + "rev": "c8d18ba345730019c3faf412c96a045ade171895", "type": "github" }, "original": { @@ -209,11 +209,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1685518550, - "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "lastModified": 1687709756, + "narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=", "owner": "numtide", "repo": "flake-utils", - "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7", "type": "github" }, "original": { diff --git a/devenv.nix b/devenv.nix index 83b269b..9710665 100644 --- a/devenv.nix +++ b/devenv.nix @@ -113,6 +113,12 @@ in { default = ""; }; + fallbackMediaPaths = lib.mkOption { + type = lib.types.str; + description = ''Sets the paths to be redirected to the fallbackMediaUrl.''; + default = "/media/* /thumbnail/*"; + }; + additionalPackages = lib.mkOption { type = lib.types.listOf lib.types.package; description = "Additional packages to be installed"; diff --git a/docs/Options.md b/docs/Options.md index 8844d1a..4866e33 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -133,6 +133,14 @@ Fallback redirect URL for media not found on local storage. Best for CDN purpose kellerkinder.fallbackMediaUrl = "https://my-cool-cdn-in-public-staging.example-cdn.com"; ``` +# kellerkinder.fallbackMediaPaths +Sets the paths to be redirected to the fallbackMediaUrl. + +*_Example_* +``` +kellerkinder.fallbackMediaPaths = "/media/* /thumbnail/*"; +``` + # kellerkinder.additionalPackages Define additional PHP extensions that are included in the devenv environment. diff --git a/modules/caddy.nix b/modules/caddy.nix index b8cbeb4..dacbd3c 100644 --- a/modules/caddy.nix +++ b/modules/caddy.nix @@ -18,7 +18,11 @@ let encode zstd gzip - handle /media/* { + @fallbackMediaPaths { + path ${cfg.fallbackMediaPaths} + } + + handle @fallbackMediaPaths { ${lib.strings.optionalString (cfg.fallbackMediaUrl != "") '' @notStatic not file redir @notStatic ${lib.strings.removeSuffix "/" cfg.fallbackMediaUrl}{path} From 48bcc6ddffc12c6d2baf0d1a9e144043131b372c Mon Sep 17 00:00:00 2001 From: Jochen Manz Date: Mon, 10 Jul 2023 13:17:02 +0200 Subject: [PATCH 11/24] [NOTICKET] add version check on enterShell --- devenv.lock | 47 +++++++++++++++++++++++++++------------- devenv.nix | 23 ++++++++++++++++++++ docs/UPDATE.md | 1 + examples/sw5/devenv.yaml | 4 +++- examples/sw6/devenv.yaml | 4 +++- 5 files changed, 62 insertions(+), 17 deletions(-) create mode 100644 docs/UPDATE.md diff --git a/devenv.lock b/devenv.lock index afc396d..aa7b1be 100644 --- a/devenv.lock +++ b/devenv.lock @@ -3,11 +3,11 @@ "devenv": { "locked": { "dir": "src/modules", - "lastModified": 1687378457, - "narHash": "sha256-EkRX4S60BGFlQuEYJegk/9aCODPdMV6XLI+2C2HTBEI=", + "lastModified": 1688925746, + "narHash": "sha256-Lora6gsuAdVeVeGj2nD4joxTu+jZsAwySlxY1XZVq8o=", "owner": "cachix", "repo": "devenv", - "rev": "c6ac4dbf501edafe0d6860e821b9e9fff0828921", + "rev": "b058455b37d2a1833eb71bebd3d2b2aa58ce70d7", "type": "github" }, "original": { @@ -88,13 +88,29 @@ "type": "github" } }, + "kellerkinder": { + "flake": false, + "locked": { + "lastModified": 1688117435, + "narHash": "sha256-7szY1x6Co/Vg56W/2Atd6D3DIn5yxHzn6oriUDPJCWE=", + "ref": "refs/heads/main", + "rev": "8c7185a4a33c0a807825c1f14bb7cc57b15c3111", + "revCount": 173, + "type": "git", + "url": "https://github.com/kellerkinderDE/devenv-shopware" + }, + "original": { + "type": "git", + "url": "https://github.com/kellerkinderDE/devenv-shopware" + } + }, "nixpkgs": { "locked": { - "lastModified": 1687412861, - "narHash": "sha256-Z/g0wbL68C+mSGerYS2quv9FXQ1RRP082cAC0Bh4vcs=", + "lastModified": 1688918189, + "narHash": "sha256-f8ZlJ67LgEUDnN7ZsAyd1/Fyby1VdOXWg4XY/irSGrQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e603dc5f061ca1d8a19b3ede6a8cf9c9fcba6cdc", + "rev": "408c0e8c15a1c9cf5c3226931b6f283c9867c484", "type": "github" }, "original": { @@ -129,11 +145,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1686690310, - "narHash": "sha256-Ps9srIZGWpfi1SfvJ3MaIG2bTPy+28eQVyTZ55A/3vE=", + "lastModified": 1688926492, + "narHash": "sha256-vOZ2IH/G0qcqyKg8jd50zB5zWpvgkiYH1ZwoUMnCi38=", "owner": "fossar", "repo": "nix-phps", - "rev": "0983b1d334561d6526a67a0919c6631e61e01b38", + "rev": "ed5fea0442ba23522fa95072d902e7a8fa31899d", "type": "github" }, "original": { @@ -153,11 +169,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1687251716, - "narHash": "sha256-+sFS41thsB5U+lY/dBYPSmU4AJ7nz/VdM1WD35fXVeM=", + "lastModified": 1688596063, + "narHash": "sha256-9t7RxBiKWHygsqXtiNATTJt4lim/oSYZV3RG8OjDDng=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "7807e1851d95828ed98491930d2d9e7ddbe65da4", + "rev": "c8d18ba345730019c3faf412c96a045ade171895", "type": "github" }, "original": { @@ -169,6 +185,7 @@ "root": { "inputs": { "devenv": "devenv", + "kellerkinder": "kellerkinder", "nixpkgs": "nixpkgs", "phps": "phps", "pre-commit-hooks": "pre-commit-hooks" @@ -209,11 +226,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1685518550, - "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "lastModified": 1687709756, + "narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=", "owner": "numtide", "repo": "flake-utils", - "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7", "type": "github" }, "original": { diff --git a/devenv.nix b/devenv.nix index 83b269b..48d3ca8 100644 --- a/devenv.nix +++ b/devenv.nix @@ -2,6 +2,8 @@ let cfg = config.kellerkinder; + currentVersion = "v1.0.0"; + listEntries = path: map (name: path + "/${name}") (builtins.attrNames (builtins.readDir path)); in { @@ -145,6 +147,27 @@ in { services.rabbitmq.enable = cfg.enableRabbitMq; services.rabbitmq.managementPlugin.enable = cfg.enableRabbitMq; + dotenv.disableHint = true; + + scripts.versionCheck.exec = '' + AVAILABLE=$(${pkgs.curl}/bin/curl --silent "https://api.github.com/repos/kellerkinderDE/devenv-shopware/releases/latest" | ${pkgs.jq}/bin/jq -r .tag_name) + + echo "" + + if [ "$AVAILABLE" = "${currentVersion}" ]; then + echo -e "\e[32mYou are running the latest version of devenv-shopware\e[0m" + else + echo -e "\e[31mThere is a new version of devenv-shopware available: $AVAILABLE\e[0m" + echo -e "Please see https://github.com/kellerkinderDE/devenv-shopware/wiki/Update for further information" + fi + + echo "" + ''; + + enterShell = '' + versionCheck + ''; + # Environment variables env = lib.mkMerge [ (lib.mkIf cfg.enable { diff --git a/docs/UPDATE.md b/docs/UPDATE.md new file mode 100644 index 0000000..1e0ca6a --- /dev/null +++ b/docs/UPDATE.md @@ -0,0 +1 @@ +# diff --git a/examples/sw5/devenv.yaml b/examples/sw5/devenv.yaml index 3b2471b..b429dc4 100644 --- a/examples/sw5/devenv.yaml +++ b/examples/sw5/devenv.yaml @@ -2,8 +2,10 @@ allowUnfree: true imports: - kellerkinder inputs: + nixpkgs: + url: github:NixOS/nixpkgs/nixos-unstable kellerkinder: - url: git+https://github.com/kellerkinderDE/devenv-shopware + url: git+https://github.com/kellerkinderDE/devenv-shopware?ref=v1.0.0 flake: false phps: url: github:fossar/nix-phps diff --git a/examples/sw6/devenv.yaml b/examples/sw6/devenv.yaml index 2d1fee3..eb4924d 100644 --- a/examples/sw6/devenv.yaml +++ b/examples/sw6/devenv.yaml @@ -2,8 +2,10 @@ allowUnfree: true imports: - kellerkinder inputs: + nixpkgs: + url: github:NixOS/nixpkgs/nixos-unstable kellerkinder: - url: git+https://github.com/kellerkinderDE/devenv-shopware + url: git+https://github.com/kellerkinderDE/devenv-shopware?ref=v1.0.0 flake: false phps: url: github:fossar/nix-phps From 59debc68c916c4e0f99a029433036aa1fd7b01a3 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 10 Jul 2023 13:25:56 +0200 Subject: [PATCH 12/24] Update and rename UPDATE.md to Update.md Add information about changes regarding the v1.0.0 release --- docs/UPDATE.md | 1 - docs/Update.md | 12 ++++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) delete mode 100644 docs/UPDATE.md create mode 100644 docs/Update.md diff --git a/docs/UPDATE.md b/docs/UPDATE.md deleted file mode 100644 index 1e0ca6a..0000000 --- a/docs/UPDATE.md +++ /dev/null @@ -1 +0,0 @@ -# diff --git a/docs/Update.md b/docs/Update.md new file mode 100644 index 0000000..70a3ef7 --- /dev/null +++ b/docs/Update.md @@ -0,0 +1,12 @@ +# Updates + +## v1.0.0 +* You have to remove `http` and/or `https` from `kellerkinder.additionalServerAlias` +* You have to adjust your `devenv.yaml` to + ```yml + ... + kellerkinder: + url: git+https://github.com/kellerkinderDE/devenv-shopware?ref=v1.0.0 + flake: false + ... + ``` From 3ed172680732c8578702c49ec7fd1006160912d0 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 10 Jul 2023 13:27:00 +0200 Subject: [PATCH 13/24] Add information to update regarding ports --- docs/Update.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Update.md b/docs/Update.md index 70a3ef7..56e492a 100644 --- a/docs/Update.md +++ b/docs/Update.md @@ -1,7 +1,7 @@ # Updates ## v1.0.0 -* You have to remove `http` and/or `https` from `kellerkinder.additionalServerAlias` +* You have to remove `http`, `https` and the ports (eg. `8000`) from `kellerkinder.additionalServerAlias` * You have to adjust your `devenv.yaml` to ```yml ... From 2a25d60998f67bba1bbfa912bbc0c56a8cda116e Mon Sep 17 00:00:00 2001 From: Jochen Manz Date: Mon, 10 Jul 2023 13:31:48 +0200 Subject: [PATCH 14/24] update devenv.lock --- devenv.lock | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/devenv.lock b/devenv.lock index aa7b1be..0dada0c 100644 --- a/devenv.lock +++ b/devenv.lock @@ -3,11 +3,11 @@ "devenv": { "locked": { "dir": "src/modules", - "lastModified": 1688925746, - "narHash": "sha256-Lora6gsuAdVeVeGj2nD4joxTu+jZsAwySlxY1XZVq8o=", + "lastModified": 1688985196, + "narHash": "sha256-fKSISRtw4Bfth7iLmQ4sKBhW63IAkVJNYJ+TLknC+hc=", "owner": "cachix", "repo": "devenv", - "rev": "b058455b37d2a1833eb71bebd3d2b2aa58ce70d7", + "rev": "6a30b674fb5a54eff8c422cc7840257227e0ead2", "type": "github" }, "original": { @@ -88,22 +88,6 @@ "type": "github" } }, - "kellerkinder": { - "flake": false, - "locked": { - "lastModified": 1688117435, - "narHash": "sha256-7szY1x6Co/Vg56W/2Atd6D3DIn5yxHzn6oriUDPJCWE=", - "ref": "refs/heads/main", - "rev": "8c7185a4a33c0a807825c1f14bb7cc57b15c3111", - "revCount": 173, - "type": "git", - "url": "https://github.com/kellerkinderDE/devenv-shopware" - }, - "original": { - "type": "git", - "url": "https://github.com/kellerkinderDE/devenv-shopware" - } - }, "nixpkgs": { "locked": { "lastModified": 1688918189, @@ -145,11 +129,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1688926492, - "narHash": "sha256-vOZ2IH/G0qcqyKg8jd50zB5zWpvgkiYH1ZwoUMnCi38=", + "lastModified": 1688977481, + "narHash": "sha256-dy2+j59+o5T1/ZW+pQB917CcKvxGEwTNxdTchlFzJGQ=", "owner": "fossar", "repo": "nix-phps", - "rev": "ed5fea0442ba23522fa95072d902e7a8fa31899d", + "rev": "4ec97040d932805425e0d1e178ad759250e193a7", "type": "github" }, "original": { @@ -185,7 +169,6 @@ "root": { "inputs": { "devenv": "devenv", - "kellerkinder": "kellerkinder", "nixpkgs": "nixpkgs", "phps": "phps", "pre-commit-hooks": "pre-commit-hooks" From 125efca50e3d2b897169c5fcee56ce09b5f43914 Mon Sep 17 00:00:00 2001 From: "a.wink" Date: Wed, 16 Aug 2023 17:38:27 +0200 Subject: [PATCH 15/24] WIP: [noticket] Add test workflow for examples --- .github/workflows/test_examples.yml | 51 +++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/test_examples.yml diff --git a/.github/workflows/test_examples.yml b/.github/workflows/test_examples.yml new file mode 100644 index 0000000..375f07d --- /dev/null +++ b/.github/workflows/test_examples.yml @@ -0,0 +1,51 @@ +name: Test examples + +on: + pull_request: + paths: + - modules/** + - devenv.nix + - devenv.yaml + push: + paths: + - modules/** + - devenv.nix + - devenv.yaml + +env: + DEVENV_TESTING_VERSION: v0.6.3 + +jobs: + test_examples: + strategy: + matrix: + os: [ ubuntu-latest, macos-latest ] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v22 + - uses: cachix/cachix-action@v12 + with: + name: devenv + - name: Install devenv.sh + run: | + useradd nix-user && groupadd -g 30000 nixbld && usermod -a -G nixbld nix-user + echo "build-users-group = nixbld" >> /etc/nix/nix.conf + nix profile install --accept-flake-config tarball+https://install.devenv.sh/${DEVENV_TESTING_VERSION} + shell: sh + - name: Test SW6 example + run: | + echo running on branch ${GITHUB_REF##*/} + cd examples/sw6 + echo + sed -i "s/ref=v1.0.0/ref=${GITHUB_REF##*/}/g" devenv.yaml + cat devenv.yaml + devenv ci -vvv + devenv shell echo ok + - name: Test SW5 example + run: | + echo running on branch ${GITHUB_REF##*/} + cd examples/sw5 + sed -i "s/ref=v1.0.0/ref=${GITHUB_REF##*/}/g" devenv.yaml + devenv ci -vvv + devenv shell echo ok From a5f85220a449732681141a9b09fb2974c93cb5ff Mon Sep 17 00:00:00 2001 From: "a.wink" Date: Thu, 17 Aug 2023 10:35:48 +0200 Subject: [PATCH 16/24] Fix build and runtime for sw5 + sw6 tests - Remove mac tests due to sed incompatibilities --- .github/workflows/test_examples.yml | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/.github/workflows/test_examples.yml b/.github/workflows/test_examples.yml index 375f07d..5e8a342 100644 --- a/.github/workflows/test_examples.yml +++ b/.github/workflows/test_examples.yml @@ -1,26 +1,19 @@ name: Test examples on: - pull_request: - paths: - - modules/** - - devenv.nix - - devenv.yaml push: paths: + - .github/workflows/test_examples.yml - modules/** - devenv.nix - devenv.yaml env: - DEVENV_TESTING_VERSION: v0.6.3 + DEVENV_VERSION: v0.6.3 jobs: test_examples: - strategy: - matrix: - os: [ ubuntu-latest, macos-latest ] - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: cachix/install-nix-action@v22 @@ -28,24 +21,19 @@ jobs: with: name: devenv - name: Install devenv.sh - run: | - useradd nix-user && groupadd -g 30000 nixbld && usermod -a -G nixbld nix-user - echo "build-users-group = nixbld" >> /etc/nix/nix.conf - nix profile install --accept-flake-config tarball+https://install.devenv.sh/${DEVENV_TESTING_VERSION} + run: nix profile install --accept-flake-config tarball+https://install.devenv.sh/${DEVENV_VERSION} shell: sh - name: Test SW6 example run: | - echo running on branch ${GITHUB_REF##*/} + echo running on branch ${GITHUB_REF_NAME} cd examples/sw6 - echo - sed -i "s/ref=v1.0.0/ref=${GITHUB_REF##*/}/g" devenv.yaml - cat devenv.yaml + sed -i "s,kellerkinderDE/devenv-shopware?ref=v1.0.0,kellerkinderDE/devenv-shopware?ref=${GITHUB_REF_NAME}," devenv.yaml devenv ci -vvv devenv shell echo ok - name: Test SW5 example run: | - echo running on branch ${GITHUB_REF##*/} + echo running on branch ${GITHUB_REF_NAME} cd examples/sw5 - sed -i "s/ref=v1.0.0/ref=${GITHUB_REF##*/}/g" devenv.yaml + sed -i "s,kellerkinderDE/devenv-shopware?ref=v1.0.0,kellerkinderDE/devenv-shopware?ref=${GITHUB_REF_NAME}," devenv.yaml devenv ci -vvv devenv shell echo ok From 4ed1aae9801530af33a9b7f79367f4ecbb43660e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20M=C3=BCller?= <25648755+M-arcus@users.noreply.github.com> Date: Sun, 20 Aug 2023 14:04:56 +0200 Subject: [PATCH 17/24] OpenSearch: Add configuration --- devenv.nix | 9 ++++++++- docs/Options.md | 13 +++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/devenv.nix b/devenv.nix index fa26ef7..fb74387 100644 --- a/devenv.nix +++ b/devenv.nix @@ -210,6 +210,12 @@ in { description = "Enables Elasticsearch"; }; + enableOpenSearch = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Enables OpenSearch"; + }; + enableRabbitMq = lib.mkOption { type = lib.types.bool; default = false; @@ -418,6 +424,7 @@ in { services.mailhog.enable = true; services.elasticsearch.enable = cfg.enableElasticsearch; + services.opensearch.enable = cfg.enableOpenSearch; services.rabbitmq.enable = cfg.enableRabbitMq; services.rabbitmq.managementPlugin.enable = cfg.enableRabbitMq; @@ -441,7 +448,7 @@ in { NODE_OPTIONS = "--openssl-legacy-provider --max-old-space-size=2000"; }) - (lib.mkIf config.services.elasticsearch.enable { + (lib.mkIf (config.services.elasticsearch.enable || config.services.opensearch.enable) { SHOPWARE_ES_ENABLED = "1"; SHOPWARE_ES_INDEXING_ENABLED = "1"; SHOPWARE_ES_HOSTS = "127.0.0.1"; diff --git a/docs/Options.md b/docs/Options.md index f497f1e..775a77b 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -65,14 +65,23 @@ kellerkinder.enableRabbitMq = true; ``` # kellerkinder.enableElasticsearch -Enables the Elasticsearch service and configures Shopware to use Elasticsearch in addition to the default -MySQL search. +Enables the Elasticsearch service and configures Shopware to use Elasticsearch in addition to the default MySQL search. +Only one of kellerkinder.enableElasticsearch or kellerkinder.enableOpenSearch should be enabled. *_Example_* ``` kellerkinder.enableElasticsearch = true; ``` +# kellerkinder.enableOpenSearch +Enables the OpenSearch service and configures Shopware to use OpenSearch in addition to the default MySQL search. +Only one of kellerkinder.enableElasticsearch or kellerkinder.enableOpenSearch should be enabled. + +*_Example_* +``` +kellerkinder.enableOpenSearch = true; +``` + # kellerkinder.importDatabaseDumps You can import a list of links of database dumps by using the command `importdb`. From 67021e5635c08896f42bd1a4860f62009457547f Mon Sep 17 00:00:00 2001 From: "a.wink" Date: Mon, 21 Aug 2023 07:53:15 +0200 Subject: [PATCH 18/24] Add pull_request handling for tests based on branches --- .github/workflows/test_examples.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test_examples.yml b/.github/workflows/test_examples.yml index 5e8a342..2c6c772 100644 --- a/.github/workflows/test_examples.yml +++ b/.github/workflows/test_examples.yml @@ -1,6 +1,11 @@ name: Test examples on: + pull_request: + branches: + - main + - integration/** + - v** push: paths: - .github/workflows/test_examples.yml From 026cbbd923c996fcc274f0068cc49da7e7ed060b Mon Sep 17 00:00:00 2001 From: "a.wink" Date: Mon, 21 Aug 2023 07:56:20 +0200 Subject: [PATCH 19/24] Add dynamic matrix for example tests --- .github/workflows/test_examples.yml | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test_examples.yml b/.github/workflows/test_examples.yml index 2c6c772..ea5c259 100644 --- a/.github/workflows/test_examples.yml +++ b/.github/workflows/test_examples.yml @@ -17,8 +17,20 @@ env: DEVENV_VERSION: v0.6.3 jobs: + list-examples: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v2 + - id: set-matrix + run: echo "::set-output name=matrix::$(ls examples/ | jq -R -s -c 'split("\n")[:-1]')" test_examples: + needs: list-examples runs-on: ubuntu-latest + strategy: + matrix: + manifest: ${{ fromJson(needs.list-examples.outputs.matrix) }} steps: - uses: actions/checkout@v3 - uses: cachix/install-nix-action@v22 @@ -28,17 +40,10 @@ jobs: - name: Install devenv.sh run: nix profile install --accept-flake-config tarball+https://install.devenv.sh/${DEVENV_VERSION} shell: sh - - name: Test SW6 example - run: | - echo running on branch ${GITHUB_REF_NAME} - cd examples/sw6 - sed -i "s,kellerkinderDE/devenv-shopware?ref=v1.0.0,kellerkinderDE/devenv-shopware?ref=${GITHUB_REF_NAME}," devenv.yaml - devenv ci -vvv - devenv shell echo ok - - name: Test SW5 example + - name: Test ${{ matrix.manifest }} example run: | echo running on branch ${GITHUB_REF_NAME} - cd examples/sw5 + cd examples/${{ matrix.manifest }} sed -i "s,kellerkinderDE/devenv-shopware?ref=v1.0.0,kellerkinderDE/devenv-shopware?ref=${GITHUB_REF_NAME}," devenv.yaml devenv ci -vvv devenv shell echo ok From 2b6b5be5bef6b99a87eadb8bd815862db1b19ada Mon Sep 17 00:00:00 2001 From: "a.wink" Date: Mon, 21 Aug 2023 08:07:05 +0200 Subject: [PATCH 20/24] Adjust branch dependency for tests - Add examples folder to tests - Update checkout action for list-examples --- .github/workflows/test_examples.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test_examples.yml b/.github/workflows/test_examples.yml index ea5c259..77b192f 100644 --- a/.github/workflows/test_examples.yml +++ b/.github/workflows/test_examples.yml @@ -4,11 +4,11 @@ on: pull_request: branches: - main - - integration/** - - v** + - release/** push: paths: - .github/workflows/test_examples.yml + - examples/** - modules/** - devenv.nix - devenv.yaml @@ -22,7 +22,7 @@ jobs: outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - id: set-matrix run: echo "::set-output name=matrix::$(ls examples/ | jq -R -s -c 'split("\n")[:-1]')" test_examples: From de556f23248dfc953fc734b9d6d942f544f4b645 Mon Sep 17 00:00:00 2001 From: "a.wink" Date: Mon, 21 Aug 2023 08:15:33 +0200 Subject: [PATCH 21/24] Adjust branch dependency for tests - Add examples folder to tests - Update checkout action for list-examples - Update deprecated output handling --- .github/workflows/test_examples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_examples.yml b/.github/workflows/test_examples.yml index 77b192f..9658d2e 100644 --- a/.github/workflows/test_examples.yml +++ b/.github/workflows/test_examples.yml @@ -24,7 +24,7 @@ jobs: steps: - uses: actions/checkout@v3 - id: set-matrix - run: echo "::set-output name=matrix::$(ls examples/ | jq -R -s -c 'split("\n")[:-1]')" + run: echo "matrix=$(ls examples/ | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT test_examples: needs: list-examples runs-on: ubuntu-latest From e495da8364ac54ee3eee3f924245492330215c0e Mon Sep 17 00:00:00 2001 From: "a.wink" Date: Tue, 22 Aug 2023 09:17:05 +0200 Subject: [PATCH 22/24] Add release and test badge to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index bdfd1b2..f04133f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ # Kellerkinder devenv +[![GitHub Release](https://img.shields.io/github/v/release/kellerkinderDE/devenv-shopware.svg?style=flat)](https://github.com/kellerkinderDE/devenv-shopware/releases) +[![Example tests](https://github.com/kellerkinderDE/devenv-shopware/actions/workflows/test_examples.yml/badge.svg)](https://github.com/kellerkinderDE/devenv-shopware/actions/workflows/test_examples.yml) devenv provides a reproducible and declarative local development environment for our [Shopware](https://www.shopware.com) projects. It uses the [Nix package system](https://nixos.org/) to provide native packages for all our required services. This environment is From 560f9998f139cfa2d3daf32a07687d7f50660199 Mon Sep 17 00:00:00 2001 From: "a.wink" Date: Tue, 22 Aug 2023 12:51:00 +0200 Subject: [PATCH 23/24] HOTFIX: Fix default value of openSearch option --- devenv.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devenv.nix b/devenv.nix index 17c138d..8036343 100644 --- a/devenv.nix +++ b/devenv.nix @@ -70,8 +70,8 @@ in { enableOpenSearch = lib.mkOption { type = lib.types.bool; - default = true; description = "Enables OpenSearch"; + default = false; }; enableRabbitMq = lib.mkOption { From 2b0739c8c81efc86373da5ea74a2da62c0c97dd2 Mon Sep 17 00:00:00 2001 From: "a.wink" Date: Tue, 22 Aug 2023 12:53:10 +0200 Subject: [PATCH 24/24] Remove `ESC` char from Docs --- docs/Update.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Update.md b/docs/Update.md index 56e492a..4ee72a3 100644 --- a/docs/Update.md +++ b/docs/Update.md @@ -1,7 +1,7 @@ # Updates ## v1.0.0 -* You have to remove `http`, `https` and the ports (eg. `8000`) from `kellerkinder.additionalServerAlias` +* You have to remove `http`, `https` and the ports (eg. `8000`) from `kellerkinder.additionalServerAlias` * You have to adjust your `devenv.yaml` to ```yml ...