Skip to content

Instantly share code, notes, and snippets.

@SGrimmel

SGrimmel/Error Secret

Created May 3, 2024 11:29
Show Gist options
  • Save SGrimmel/d40fad0a03537f5fe4d6c69bb58707a3 to your computer and use it in GitHub Desktop.
Save SGrimmel/d40fad0a03537f5fe4d6c69bb58707a3 to your computer and use it in GitHub Desktop.
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1714719003,
"owner": "cachix",
"repo": "devenv",
"rev": "4d786c35280e94211b2fb7b50036cc6aeddee320",
"treeHash": "09fbabb734953977376a499dc75685d35584bef1",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"treeHash": "2addb7b71a20a25ea74feeaf5c2f6a6b30898ecb",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"treeHash": "bd263f021e345cb4a39d80c126ab650bebc3c10c",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"treeHash": "ca14199cabdfe1a06a7b1654c76ed49100a689f9",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1714656196,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "94035b482d181af0a0f8f77823a790b256b7c3cc",
"treeHash": "610e9f9d128a98317ba158e36778fce1c87cb67b",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1714531828,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "0638fe2715d998fa81d173aad264eb671ce2ebc1",
"treeHash": "f72314bde6c77cbdf35f68581c4758f9ff28461f",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1714478972,
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "2849da033884f54822af194400f8dff435ada242",
"treeHash": "578180deb59a545b0032e9a66da4c0c043c5057d",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"treeHash": "cce81f2a0f0743b2eb61bc2eb6c7adbe2f2c6beb",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}
{ pkgs, lib, config, ... }:
{
dotenv.enable = true;
devenv.latestVersion = "1.0.4";
certificates = [
"*.xxx.local"
];
packages = [
pkgs.jq
pkgs.gnupatch
pkgs.nodePackages_latest.yalc
pkgs.gnused
pkgs.symfony-cli
pkgs.deno
pkgs.shopware-cli
pkgs.pigz
];
languages.javascript = {
enable = lib.mkDefault true;
package = lib.mkDefault pkgs.nodejs-18_x;
};
languages.php = {
enable = lib.mkDefault true;
version = lib.mkDefault "8.2";
extensions = [ "xdebug" "amqp" "redis" "igbinary" ];
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:6379/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
xdebug.mode = debug
xdebug.discover_client_host = 1
xdebug.client_host = 127.0.0.1
xdebug.client_port = 9000
'';
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."*.xxx.local" = lib.mkDefault {
serverAliases = [ "be.xxx.local" "it.xxx.local" "hu.xxx.local" "de.xxx.local" "fr.xxx.local" "nl.xxx.local" "sk.xxx.local" "at.xxx.local" "ch.xxx.local" "uk.xxx.local" "cz.xxx.local" "es.xxx.local" "pl.xxx.local"];
extraConfig = ''
tls .devenv/state/mkcert/_wildcard.xxx.local.pem .devenv/state/mkcert/_wildcard.xxx.local-key.pem
@default {
not path /theme/* /media/* /thumbnail/* /bundles/* /css/* /fonts/* /js/* /sitemap/*
}
root * public
php_fastcgi @default unix/${config.languages.php.fpm.pools.web.socket} {
trusted_proxies private_ranges
}
encode zstd gzip
file_server
log {
output stderr
format console
level ERROR
}
'';
};
};
services.mysql = {
enable = true;
package = pkgs.mariadb;
initialDatabases = lib.mkDefault [{ name = "shopware"; }];
ensureUsers = lib.mkDefault [
{
name = "shopuser";
password = "secret";
ensurePermissions = {
"shopware.*" = "ALL PRIVILEGES";
"shopware_test.*" = "ALL PRIVILEGES";
};
}
];
settings = {
mysqld = {
log_bin_trust_function_creators = 1;
};
};
};
services.rabbitmq = {
enable = true;
managementPlugin.enable = true;
};
services.redis.enable = lib.mkDefault true;
services.mailhog.enable = lib.mkDefault true;
#services.adminer.enable = lib.mkDefault false;
# services.minio.enable = true;
services.elasticsearch = {
enable = true;
extraConf = ''
xpack.security.enabled: false
'';
};
# Environment variables
#env.APP_URL = lib.mkDefault "https://de.xxx.local";
#env.APP_SECRET = lib.mkDefault "devsecret";
env.DATABASE_URL = lib.mkForce "mysql://shopuser:secret@localhost:3306/shopware";
env.REDIS_SESSION_HOST = lib.mkForce "localhost";
env.REDIS_CACHE_HOST = lib.mkForce "localhost";
env.RABBITMQ_URL = lib.mkForce "amqp://guest:guest@localhost:5672/%2F";
#env.MAILER_DSN = lib.mkDefault "smtp://localhost:1025";
# General cypress
env.CYPRESS_baseUrl = lib.mkDefault "https://de.xxx.local";
env.CYPRESS_dbHost = lib.mkDefault "localhost";
env.CYPRESS_dbUser = lib.mkDefault "shopuser";
env.CYPRESS_dbPassword = lib.mkDefault "secret";
env.CYPRESS_dbName = lib.mkDefault "shopware";
env.NODE_OPTIONS = lib.mkDefault "--openssl-legacy-provider";
# db scripts
scripts.db-dump.exec = "mysqldump -u root shopware | sed -E 's/DEFINER=[^ *]+/DEFINER=CURRENT_USER/g' > ./docker/db-dumps/db-dump.sql";
scripts.db-import.exec = ''
git lfs pull
mysql -u root < ./development/dev-before-import.sql
${pkgs.gzip}/bin/gunzip -q -c "./docker/db-dumps/db-dump.sql.gz" > "./docker/db-dumps/db-dump.sql"
mysql -u root shopware < ./docker/db-dumps/db-dump.sql
mysql -u root shopware < ./development/dev-migration.sql
addadminuser
'';
scripts.db-migrate.exec = ''
bin/console database:migrate --all
bin/console database:migrate Netformic --all
'';
scripts.db-dump-main.exec = "platform db:dump -e main --gzip -f docker/db-dumps/db-dump.sql.gz -p 4xbjvlwpxpsbu -A shopware";
# "build-php" prepares all the php/symfony/shopware stuff
scripts.build-php.exec = ''
composer install --no-scripts
bin/console plugin:refresh
bin/console plugin:install -a DeploymentHelper
bin/console plugin:update DeploymentHelper
bin/console nf:deployment:plugins:deploy environment/dev/plugins.yml --uninstall
'';
# "build-js" is to be used for rebuilding all the JS stuff
scripts.build-js.exec = ''
bin/console bundle:dump
bin/build-administration.sh &
bin/build-storefront.sh &
wait
bin/console assets:install
bin/console xxx:theme:compile
'';
# "rebuild" should be used when updating the local app with remote changes
scripts.rebuild.exec = ''
build-php
db-migrate
build-js
refresh-index
'';
# refresh index
scripts.refresh-index.exec = ''
bin/console messenger:setup-transports
bin/console dal:refresh:index --use-queue
bin/console messenger:stats
process-queue
'';
scripts.process-queue.exec = ''
bin/console messenger:consume default async ProductIndexingMessage ScheduledTask CategoryIndexingMessage -v &
'';
# "initialize" should be used only on initial project setup
scripts.init.exec = ''
db-import
bin/console system:generate-jwt-secret || true
rebuild
addadminuser
'';
scripts.clean.exec = ''
find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +
rm -rf vendor
'';
scripts.addadminuser.exec = lib.mkDefault "bin/console user:create --admin --password=shopware --no-interaction admin";
# development scripts
scripts.phpcs.exec = "vendor/bin/phpcbf custom/static-plugins --runtime-set ignore_warnings_on_exit true -pq --colors --standard=PSR12 --ignore=\".js,**/tests/**/*.php\"";
scripts.phpstan.exec = "vendor/bin/phpstan analyse --memory-limit=512M";
scripts.test-unit.exec = "vendor/bin/phpunit --configuration phpunit.unit.xml --testdox --color";
scripts.test-integration.exec = "vendor/bin/phpunit --configuration phpunit.integration.xml --testdox --color";
scripts.test-e2e.exec = ''
cd tests/Cypress
npm install
NODE_OPTIONS="" ./node_modules/.bin/cypress run --headless --spec "cypress/e2e/**/*"
'';
scripts.ui-e2e.exec = ''
cd tests/Cypress
npm install
NODE_OPTIONS="" ./node_modules/.bin/cypress open
'';
# Shopware 6 related scripts
scripts.build-storefront.exec = lib.mkDefault "bin/build-storefront.sh";
scripts.watch-storefront.exec = lib.mkDefault "bin/watch-storefront.sh";
scripts.build-administration.exec = lib.mkDefault "bin/build-administration.sh";
scripts.watch-administration.exec = lib.mkDefault "bin/watch-administration.sh ";
scripts.theme-refresh.exec = lib.mkDefault "bin/console theme:refresh";
scripts.theme-compile.exec = lib.mkDefault "bin/console theme:compile";
scripts.start-debug-worker.exec = ''
php -dxdebug.mode=debug -dxdebug.client_host=127.0.0.1 -dxdebug.client_port=9000 -dxdebug.start_with_request=yes bin/console messenger:consume -vv async
'';
}
allowUnfree: true
inputs:
nixpkgs:
url: github:NixOS/nixpkgs/nixpkgs-unstable
(devenv) bash-5.2$ composer install
No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.
Loading composer repositories with package information
Cannot create cache directory /Users/xxx.xxx/Library/Caches/composer/repo/https---packages.shopware.com/, or directory is not writable. Proceeding without cache. See also cache-read-only config if your filesystem is read-only.
In CurlDownloader.php line 364:
curl error 23 while downloading https://packages.shopware.com/packages.json: Failed writing received data to disk/application
install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--download-only] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-progress] [--no-install] [--audit] [--audit-format AUDIT-FORMAT] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [<packages>...]

Option 1: Manual installation

nix

$ sh <(curl -L https://nixos.org/nix/install)

close terminal and open again

cache

$ nix-env -iA cachix -f https://cachix.org/api/v1/install
$ cachix use devenv

devenv

$ nix-env -if https://github.com/cachix/devenv/tarball/latest
$ cachix use shopware

Terminal 1

Start your local dev environment wait until everything is running and leave the terminal open

$ devenv up

Terminal 2

Now start a second terminal and run the command below. This will initialize the development environment (import db dump, composer install, migrations, build storefront/admin)

$ devenv shell init
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment