{ withSystem, ... }: let name = "ptest"; in { perSystem = psArgs@{ pkgs, ... }: with pkgs; { packages.${name} = writeShellApplication { inherit name; runtimeInputs = [ psArgs.config.packages.onchange ]; text = '' command="phpunit" args=("--colors") bin="vendor/bin" if [[ -x "$bin/pest" ]]; then command="pest" args=() fi onchange "**/*.php" \ "$bin/$command ''${args[*]} $*" ''; }; }; flake.modules.homeManager.base = { pkgs, ... }: { home.packages = [ (withSystem pkgs.system (psArgs: psArgs.config.packages.${name})) ]; }; }