Skip to content

Instantly share code, notes, and snippets.

@charlycoste
Last active September 3, 2020 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save charlycoste/1439ad33166da9fb498d6483181c5aeb to your computer and use it in GitHub Desktop.
Save charlycoste/1439ad33166da9fb498d6483181c5aeb to your computer and use it in GitHub Desktop.
Sample shell.nix for Sylius project (PHP)
.PHONY: build install test
build:
composer install --no-scripts
bin/console assets:install
bin/console sylius:install:assets
bin/console sylius:theme:assets:install
yarn install
yarn run build
yarn encore dev
install:
bin/console cache:warmup
bin/console doctrine:schema:update -n
test: vendor
bin/phpunit --coverage-text --coverage-html=var/coverage --colors=never
# see https://github.com/NixOS/nixpkgs/blob/776f12b39ec436ea31c57ecf755464b175d765d9/doc/languages-frameworks/php.section.md
{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/eac5ef8aa9c0ddd948b20e83d9d7b37cd0132a81.tar.gz") {}, debug ? false }:
with pkgs;
let
symfony-cli = stdenv.mkDerivation rec {
version = "4.18.4";
pname = "symfony-cli";
src = fetchurl {
url = "https://github.com/symfony/cli/releases/download/v${version}/symfony_linux_amd64.gz";
sha256 = "1fqx2kn1jm2a467nvc3b4jgcwrhz5mg5llsc0x1257qg41x5a2rq";
};
phases = [
"unpackPhase"
"installPhase"
];
unpackPhase = "zcat $src > symfony";
installPhase = ''
mkdir -p $out/bin
install -m 755 symfony $out/bin
'';
};
php_for_sylius = php74.buildEnv {
extraConfig = ''
short_open_tag=0
memory_limit=-1
date.timezone=Europe/Paris
'';
extensions = { all, ... }: with all; [
# Mandatory
filter
iconv
ctype
redis
tokenizer
simplexml
# Recommendations
dom
posix
intl
opcache
# Optional
pdo_sqlite
pdo_mysql
pdo_pgsql
openssl
calendar
soap
mbstring
exif
fileinfo
gd
curl
zip
xmlwriter
] ++ (if debug then [xdebug] else []);
};
in
mkShell {
name = "dev-shell";
COMPOSE_FILE = "docker-compose.services.yml";
shellHook = ''
alias dcd='docker-compose down'
alias dce='docker-compose exec'
alias dcl='docker-compose logs -f'
alias dcps='docker-compose ps'
alias dcr='docker-compose run'
alias dcstart='docker-compose start'
alias dcstop='docker-compose stop'
alias dcu='docker-compose up'
'';
buildInputs = [
symfony-cli
nssTools
yarn
php_for_sylius
php_for_sylius.packages.composer
];
}
@charlycoste
Copy link
Author

charlycoste commented Sep 3, 2020

Without codecoverage (faster)

nix-shell --pure --run "make && make install && make test"

With codecoverage (slower)

nix-shell --pure --arg debug true --run "make && make install && make test"

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