fediverse-feed-wrappers/shell.nix
2024-12-11 19:53:56 +01:00

94 lines
1.8 KiB
Nix

{pkgs ? import <nixpkgs> { }}:
let
php = pkgs.php84.buildEnv {
extensions = { enabled, all }: enabled ++ (with all; [
xdebug
]);
extraConfig = ''
xdebug.mode = debug
memory_limit = 4G
'';
};
inherit (php.packages) composer;
projectInstall = pkgs.writeShellApplication {
name = "project-install";
runtimeInputs = [
php
composer
projectTest
];
text = ''
composer install
project-test
'';
};
projectTest = pkgs.writeShellApplication {
name = "project-test";
runtimeInputs = [
php
];
text = ''
export PHP_CS_FIXER_IGNORE_ENV=1
./vendor/bin/phpunit
./vendor/bin/php-cs-fixer fix --dry-run --allow-risky=yes
'';
};
projectRun = pkgs.writeShellApplication {
name = "project-run";
runtimeInputs = [
php
];
text = ''
php -S 127.0.0.1:8080 -t public
'';
};
projectDeploy = pkgs.writeShellApplication {
name = "project-deploy";
runtimeInputs = [
pkgs.git
pkgs.rsync
# Missing ssh
php
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.mkShellNoCC {
name = "Fediverse-Feed-Wrappers";
buildInputs = [
php
composer
projectInstall
projectTest
projectRun
projectDeploy
];
}