Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added devenv.sh recipe #28

Merged
merged 1 commit into from
Dec 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions frosh/devenv-meta/0.1/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"aliases": ["devenv"],
"copy-from-recipe": {
"root/": ""
},
"gitignore": [
".devenv*",
"devenv.local.nix"
]
}
11 changes: 11 additions & 0 deletions frosh/devenv-meta/0.1/post-install.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
* <fg=blue>Setup</> devenv:

1. Install the Nix package manager - <comment>https://nixos.org/download.html#download-nix</>
2. Install devenv - <comment>https://devenv.sh/getting-started/</>

* <fg=blue>Run</> devenv:

1. <comment>devenv shell</> activates your developer environment
2. <comment>devenv up</> starts processes

* <fg=blue>Read</> the documentation at <comment>https://devenv.sh/getting-started/</>
6 changes: 6 additions & 0 deletions frosh/devenv-meta/0.1/root/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export NIXPKGS_ALLOW_UNFREE=1

watch_file devenv.nix
watch_file devenv.yaml
watch_file devenv.lock
eval "$(devenv print-dev-env)"
138 changes: 138 additions & 0 deletions frosh/devenv-meta/0.1/root/devenv.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1671809725,
"narHash": "sha256-hVlLu+pX+e/JIFyOAMN6bTSY47s3TdVQYPGC7yhd3JU=",
"owner": "cachix",
"repo": "devenv",
"rev": "e1ae16d5d9053512301e41e040bf3bb9b3b5c672",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1668681692,
"narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "009399224d5e398d03b22badca40a37ac85412a1",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1660459072,
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1671788672,
"narHash": "sha256-tLkPxJuos3jki2f/TZdHn+NuMQAzN9s2E4QudylQLg0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "2c74fcd6c5fc14a61de158fb796243543f46b217",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1671271954,
"narHash": "sha256-cSvu+bnvN08sOlTBWbBrKaBHQZq8mvk8bgpt0ZJ2Snc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "d513b448cc2a6da2c8803e3c197c9fc7e67b19e3",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-22.05",
"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": 1671452357,
"narHash": "sha256-HqzXiQEegpRQ4VEl9pEPgHSIxhJrNJ27HfN1wOc7w2E=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "200790e9c77064c53eaf95805b013d96615ecc27",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks"
}
}
},
"root": "root",
"version": 7
}
114 changes: 114 additions & 0 deletions frosh/devenv-meta/0.1/root/devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{ pkgs, config, ... }:

{
enterShell = ''
rm -f .devenv/profile
ln -sf ${pkgs.buildEnv { name = "devenv"; paths = config.packages; ignoreCollisions = true; }}/bin .devenv/profile
'';

packages = [
pkgs.jq
];

languages.javascript.enable = true;
languages.javascript.package = pkgs.nodejs-16_x;
env.NODE_OPTIONS = "--openssl-legacy-provider";

languages.php.enable = true;
languages.php.package = pkgs.php.buildEnv {
extensions = { all, enabled }: with all; enabled ++ [ amqp redis ];
extraConfig = ''
memory_limit = 2G
pdo_mysql.default_socket = ''${MYSQL_UNIX_PORT}
mysqli.default_socket = ''${MYSQL_UNIX_PORT}
realpath_cache_ttl = 3600
session.gc_probability = 0
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
'';
};

languages.php.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;
};
};

services.caddy.enable = true;
services.caddy.virtualHosts.":8000" = {
extraConfig = ''
root * public
php_fastcgi unix/${config.languages.php.fpm.pools.web.socket}
encode zstd gzip
file_server
log {
output stderr
format console
level ERROR
}
'';
};

services.mysql.enable = true;
services.mysql.initialDatabases = [{ name = "shopware"; }];
services.mysql.ensureUsers = [
{
name = "shopware";
password = "shopware";
ensurePermissions = { "shopware.*" = "ALL PRIVILEGES"; };
}
];

services.redis.enable = true;
services.adminer.enable = true;
services.adminer.listen = "127.0.0.1:8010";
services.mailhog.enable = true;

#services.rabbitmq.enable = true;
#services.rabbitmq.managementPlugin.enable = true;
#elasticsearch.enable = true;

# Environment variables
env.DATABASE_URL = "mysql://shopware:shopware@localhost:3306/shopware";

processes.entryscript = {
exec = (pkgs.writeShellScript "complex-process" ''
composer install --prefer-dist --no-progress --no-scripts --no-interaction

if [ ! -f "install.lock" ]; then
bin/console system:install --basic-setup
fi

echo "—————————————————————————————————————"
echo "💙 Your Shopware instance is ready 💙"
echo "—————————————————————————————————————"
sleep infinity
'').outPath;
};

# Shopware 6 related scripts
scripts.build-js.exec = "bin/build-js.sh";
scripts.build-storefront.exec = "bin/build-storefront.sh";
scripts.watch-storefront.exec = "bin/watch-storefront.sh";
scripts.build-administration.exec = "bin/build-administration.sh";
scripts.watch-administration.exec = "bin/watch-administration.sh";
scripts.theme-refresh.exec = "bin/console theme-refresh";
scripts.theme-compile.exec = "bin/console theme-compile";

# Symfony related scripts
scripts.cc.exec = "bin/console cache:clear";
}
3 changes: 3 additions & 0 deletions frosh/devenv-meta/0.1/root/devenv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
inputs:
nixpkgs:
url: github:NixOS/nixpkgs/nixpkgs-unstable