Add nix flake checks

This commit is contained in:
Tristan Daniël Maat 2022-08-03 01:47:50 +01:00
parent d6cb49a0d1
commit 056acbf397
Signed by: tlater
GPG key ID: 49670FD774E43268
3 changed files with 74 additions and 3 deletions

61
nix/checks.nix Normal file
View file

@ -0,0 +1,61 @@
{
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.json
../.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} > $out/check.log") checkCommands)}
'';
doCheck = true;
dontBuild = true;
dontInstall = true;
}
// extraAttrs);
in {
style = mkNodeCheck {
checkCommands = [
"npm run style"
];
};
types = mkNodeCheck {
checkCommands = [
"npm run check"
];
};
}