This repository has been archived on 2022-09-16. You can view files and clone it, but cannot push or open issues/pull-requests.
tlaternet-templates/nix/checks.nix

68 lines
1.3 KiB
Nix

{
self,
nix-filter,
pkgs,
}: let
inherit (builtins) removeAttrs;
inherit (pkgs.lib) concatStringsSep;
mkNodeCheck = {
buildInputs ? [],
checkCommands,
...
} @ attrs: let
extraAttrs = removeAttrs attrs ["buildInputs"];
in
self.packages.${pkgs.system}.default.overrideAttrs (old:
{
src = nix-filter {
root = self;
include = [
../package.json
../tsconfig.json
../.eslintrc.yaml
../.parcelrc
../.posthtmlrc
../.prettierrc
nix-filter.isDirectory
(nix-filter.matchExt "ts")
(nix-filter.matchExt "tsx")
(nix-filter.matchExt "html")
(nix-filter.matchExt "scss")
];
};
buildInputs = old.buildInputs ++ buildInputs;
checkPhase = ''
mkdir -p $out
${concatStringsSep "\n" (map (command: "${command} | tee $out/check.log") checkCommands)}
'';
doCheck = true;
dontBuild = true;
dontInstall = true;
}
// extraAttrs);
in {
style = mkNodeCheck {
checkCommands = [
"npm run style"
];
};
types = mkNodeCheck {
checkCommands = [
"npm run check"
];
};
lints = mkNodeCheck {
checkCommands = [
"npm run lint"
];
};
}