fediverse-feed-wrappers/shell.nix

88 lines
1.8 KiB
Nix
Raw Normal View History

2023-02-16 08:33:59 +01:00
{ pkgs ? import <nixpkgs> { } }:
let
projectInstall = pkgs.writeShellApplication {
name = "project-install";
runtimeInputs = [
pkgs.php82
pkgs.php82Packages.composer
2023-02-16 09:57:36 +01:00
projectTest
2023-02-16 08:33:59 +01:00
];
text = ''
composer install --working-dir="$PROJECT_ROOT"
2023-02-16 09:57:36 +01:00
project-test
'';
};
projectTest = pkgs.writeShellApplication {
name = "project-test";
runtimeInputs = [
pkgs.php82
];
text = ''
./vendor/bin/phpunit
./vendor/bin/php-cs-fixer fix --dry-run --allow-risky=yes
2023-02-16 08:33:59 +01:00
'';
};
projectRun = pkgs.writeShellApplication {
name = "project-run";
runtimeInputs = [
pkgs.php82
];
text = ''
php -S 127.0.0.1:8080 -t public
'';
};
2023-02-16 08:33:59 +01:00
projectDeploy = pkgs.writeShellApplication {
name = "project-deploy";
runtimeInputs = [
pkgs.git
pkgs.rsync
# Missing ssh
pkgs.php82
pkgs.php82Packages.composer
projectInstall
];
text = ''
echo "Clean file system"
git clean -dfx
echo "Install project"
project-install
echo "Install project for production"
composer install --no-dev --optimize-autoloader
echo "Sync project to production"
rsync \
-vaz \
--copy-dirlinks \
--delete \
--exclude vendor/**/.git \
src vendor public \
daniel-siepmann.de:webs/fediverse-feed-wrappers/htdocs/
echo "Clean file system"
git clean -dfx
echo "Install project"
project-install
'';
};
in pkgs.mkShell {
name = "Fediverse-Feed-Wrappers";
buildInputs = [
pkgs.php82
pkgs.php82Packages.composer
projectInstall
2023-02-16 09:57:36 +01:00
projectTest
projectRun
2023-02-16 08:33:59 +01:00
projectDeploy
];
shellHook = ''
export PROJECT_ROOT="$(pwd)"
export PATH="$(pwd)/:$PATH"
2023-02-16 09:57:36 +01:00
export PHP_CS_FIXER_IGNORE_ENV=1
2023-02-16 08:33:59 +01:00
'';
}