mirror of
https://codeberg.org/icewind/flakelight-php.git
synced 2026-06-03 09:54:20 +02:00
add psalm check
This commit is contained in:
parent
052e3c8dc7
commit
d6b95b950d
2 changed files with 50 additions and 8 deletions
31
checks/phpstan.nix
Normal file
31
checks/phpstan.nix
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
{
|
||||||
|
composerMeta,
|
||||||
|
src,
|
||||||
|
phpstan,
|
||||||
|
vendor,
|
||||||
|
stdenvNoCC,
|
||||||
|
}: let
|
||||||
|
inherit (composerMeta) version name;
|
||||||
|
in
|
||||||
|
stdenvNoCC.mkDerivation {
|
||||||
|
inherit src version;
|
||||||
|
pname = "${name}-phpstan";
|
||||||
|
|
||||||
|
nativeBuildInputs = [phpstan];
|
||||||
|
|
||||||
|
postPatch = ''
|
||||||
|
ln -s ${vendor}/vendor vendor
|
||||||
|
'';
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
|
||||||
|
phpstan analyse
|
||||||
|
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
touch $out
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
@ -40,6 +40,7 @@
|
||||||
})
|
})
|
||||||
composerJson;
|
composerJson;
|
||||||
hasPsalm = pathExists config.psalmConfig;
|
hasPsalm = pathExists config.psalmConfig;
|
||||||
|
hasPhpStan = pathExists config.phpStanConfig;
|
||||||
hasPhpCsFixer = pathExists config.phpCsFixerConfig;
|
hasPhpCsFixer = pathExists config.phpCsFixerConfig;
|
||||||
buildPhpVersion = pkgs: version:
|
buildPhpVersion = pkgs: version:
|
||||||
(phpVersions.${version} pkgs).buildEnv {
|
(phpVersions.${version} pkgs).buildEnv {
|
||||||
|
|
@ -70,6 +71,10 @@ in
|
||||||
type = with types; path;
|
type = with types; path;
|
||||||
default = src + /psalm.xml;
|
default = src + /psalm.xml;
|
||||||
};
|
};
|
||||||
|
phpStanConfig = mkOption {
|
||||||
|
type = with types; path;
|
||||||
|
default = src + /phpstan.neon;
|
||||||
|
};
|
||||||
phpCsFixerConfig = mkOption {
|
phpCsFixerConfig = mkOption {
|
||||||
type = with types; path;
|
type = with types; path;
|
||||||
default = src + /.php-cs-fixer.dist.php;
|
default = src + /.php-cs-fixer.dist.php;
|
||||||
|
|
@ -87,7 +92,7 @@ in
|
||||||
|| file.hasExt "stub"
|
|| file.hasExt "stub"
|
||||||
|| file.hasExt "phpstub"
|
|| file.hasExt "phpstub"
|
||||||
|| match "snapshot__.*\.snap" file.name != null
|
|| match "snapshot__.*\.snap" file.name != null
|
||||||
|| elem file.name [".php-cs-fixer.dist.php" "psalm.xml" "package.json" "package.lock"])
|
|| elem file.name [".php-cs-fixer.dist.php" "psalm.xml" "package.json" "package.lock" "phpstan.neon"])
|
||||||
src;
|
src;
|
||||||
};
|
};
|
||||||
phpExtensions = mkOption {
|
phpExtensions = mkOption {
|
||||||
|
|
@ -116,7 +121,7 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
inherit composerMeta filteredSrc;
|
inherit composerMeta filteredSrc;
|
||||||
inherit (final.minPhp.packages) php-cs-fixer composer psalm;
|
inherit (final.minPhp.packages) php-cs-fixer composer psalm phpstan;
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -136,17 +141,23 @@ in
|
||||||
vendor = pkgs: pkgs.vendor;
|
vendor = pkgs: pkgs.vendor;
|
||||||
};
|
};
|
||||||
|
|
||||||
checks = {pkgs, ...}: (optionalAttrs hasPsalm {
|
checks = {pkgs, ...}:
|
||||||
|
(optionalAttrs hasPsalm {
|
||||||
psalm = pkgs.callPackage ./checks/psalm.nix {
|
psalm = pkgs.callPackage ./checks/psalm.nix {
|
||||||
src = filteredSrc;
|
src = filteredSrc;
|
||||||
};
|
};
|
||||||
|
})
|
||||||
|
// (optionalAttrs hasPhpStan {
|
||||||
|
phpstan = pkgs.callPackage ./checks/phpstan.nix {
|
||||||
|
src = filteredSrc;
|
||||||
|
};
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
{
|
{
|
||||||
devShells = {
|
devShells = {
|
||||||
default = {
|
default = {
|
||||||
packages = pkgs: (config.tools pkgs) ++ (with pkgs; [minPhp php-cs-fixer composer psalm]);
|
packages = pkgs: (config.tools pkgs) ++ (with pkgs; [minPhp php-cs-fixer composer psalm phpstan]);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue