mirror of
https://codeberg.org/icewind/flakelight-php.git
synced 2026-06-03 09:54:20 +02:00
psalm check
This commit is contained in:
parent
1eceb2ce73
commit
341f512bd5
4 changed files with 85 additions and 8 deletions
31
checks/psalm.nix
Normal file
31
checks/psalm.nix
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
composerMeta,
|
||||
src,
|
||||
psalm,
|
||||
vendor,
|
||||
stdenvNoCC,
|
||||
}: let
|
||||
inherit (composerMeta) version name;
|
||||
in
|
||||
stdenvNoCC.mkDerivation {
|
||||
inherit src version;
|
||||
pname = "${name}-psalm";
|
||||
|
||||
nativeBuildInputs = [psalm];
|
||||
|
||||
postPatch = ''
|
||||
ln -s ${vendor}/vendor vendor
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
psalm --no-cache
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
touch $out
|
||||
'';
|
||||
}
|
||||
|
|
@ -43,5 +43,10 @@ in
|
|||
phpConstraint = composerJson.require.php;
|
||||
matches = matchesConstraint phpConstraint;
|
||||
in {
|
||||
inherit (composerJson) name;
|
||||
version =
|
||||
if (composerJson ? version)
|
||||
then composerJson.version
|
||||
else "0.0.0";
|
||||
phpVersions = filter matches allVersions;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
23
pkgs/vendor.nix
Normal file
23
pkgs/vendor.nix
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
composerMeta,
|
||||
vendorHash,
|
||||
runCommand,
|
||||
composerJson,
|
||||
composerLock,
|
||||
php,
|
||||
}: let
|
||||
inherit (composerMeta) version name;
|
||||
in
|
||||
php.mkComposerVendor {
|
||||
src = runCommand "${name}-composer-config" {} ''
|
||||
mkdir $out
|
||||
cp ${composerJson} $out/composer.json
|
||||
cp ${composerLock} $out/composer.lock
|
||||
'';
|
||||
pname = name;
|
||||
inherit php vendorHash name version;
|
||||
|
||||
postBuild = ''
|
||||
rm -rf vendor/*/*/.git
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue