psalm check

This commit is contained in:
Robin Appelman 2025-10-25 20:13:34 +02:00
commit 341f512bd5
4 changed files with 85 additions and 8 deletions

View file

@ -6,13 +6,12 @@
src,
config,
flakelight,
inputs,
...
}: let
inherit (builtins) elem readFile pathExists match any concatLists fromJSON attrNames head;
inherit (lib) getExe map mkDefault mkIf mkMerge mkOption warnIf optionalAttrs types optionalString genAttrs hasInfix makeSearchPathOutput;
inherit (builtins) elem readFile pathExists match fromJSON attrNames head;
inherit (lib) getExe mkDefault mkIf mkMerge mkOption warnIf optionalAttrs types;
inherit (lib.fileset) fileFilter toSource unions;
inherit (flakelight.types) fileset function optFunctionTo;
inherit (flakelight.types) fileset function;
phpVersions = {
"5.6" = pkgs: pkgs.php56;
@ -80,6 +79,7 @@ in
fileFilter
(file:
file.hasExt "php"
|| file.hasExt "phpstub"
|| match "snapshot__.*\.snap" file.name != null
|| elem file.name [".php-cs-fixer.dist.php" "psalm.xml" "package.json" "package.lock"])
src;
@ -94,6 +94,9 @@ in
default = pkgs: [];
description = "extra packages to make available in the dev shells";
};
vendorHash = mkOption {
type = with types; str;
};
};
config = mkMerge [
@ -101,7 +104,13 @@ in
withOverlays = [
(final: prev: {
minPhp = buildPhp final;
inherit (final.minPhp.packages) php-cs-fixer composer;
vendor = final.callPackage ./pkgs/vendor.nix {
php = final.minPhp;
inherit (config) composerJson composerLock vendorHash;
};
inherit composerMeta filteredSrc;
inherit (final.minPhp.packages) php-cs-fixer composer psalm;
})
];
@ -111,18 +120,27 @@ in
pname = composerMeta.name;
outputs = {
lib.phpVersions = composerMeta.phpVersions;
lib = {
phpVersions = composerMeta.phpVersions;
inherit hasPsalm hasPhpCsFixer;
};
};
packages = {
vendor = pkgs: pkgs.vendor;
};
checks = {pkgs, ...}: (optionalAttrs hasPsalm {
psalm = pkgs.runCommand "psalm-check" {} "exit 1;";
psalm = pkgs.callPackage ./checks/psalm.nix {
src = filteredSrc;
};
});
})
{
devShells = {
default = {
packages = pkgs: (config.tools pkgs) ++ (with pkgs; [minPhp php-cs-fixer composer]);
packages = pkgs: (config.tools pkgs) ++ (with pkgs; [minPhp php-cs-fixer composer psalm]);
};
};