Skip to content

Commit

Permalink
fix: make pre-commit-check work in flake.nix
Browse files Browse the repository at this point in the history
  • Loading branch information
oxcabe committed Apr 7, 2024
1 parent 7bdc453 commit df109da
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
forAllSystems = f:
nixpkgs.lib.genAttrs systems (system:
f rec {
systemName = system;
pkgs = nixpkgs.legacyPackages.${system};
commonPackages = builtins.attrValues {
inherit (pkgs) nodejs;
Expand All @@ -46,32 +47,34 @@
});
in
{
pre-commit-check = pre-commit-hooks.run {
src = builtins.path { path = ./.; };
default_stages = [ "manual" "push" ];
hooks = {
nixpkgs-fmt.enable = true;
commitizen.enable = true;
biome = {
enable = true;
name = "Biome.js";
entry = "biome check --apply";
stages = [ "pre-push" ];
checks = forAllSystems ({ systemName, pkgs, ... }: {
pre-commit-check = pre-commit-hooks.lib.${systemName}.run {
src = builtins.path { path = ./.; };
default_stages = [ "manual" "push" ];
hooks = {
alejandra.settings.verbosity = "quiet";
nixpkgs-fmt.enable = true;
commitizen.enable = true;
biome = {
enable = true;
package = pkgs.biome;
name = "Biome.js";
entry = "biome check --no-errors-on-unmatched --apply";
stages = [ "pre-push" ];
};
};
};
settings = {
alejandra.verbosity = "quiet";
};
};
});

# Development environment
devShells = forAllSystems ({ pkgs, commonPackages }: {
inherit (self.pre-commit-check) shellHook;
devShells = forAllSystems ({ systemName, pkgs, commonPackages, ... }: {
default = pkgs.mkShell {
packages = with pkgs; [ nixpkgs-fmt biome ] ++ commonPackages;
inherit (self.checks.${systemName}.pre-commit-check) shellHook;
packages = commonPackages ++ self.checks.${systemName}.pre-commit-check.enabledPackages;
};
});

/*
# Build package into `dist/` dir from `pnpm-lock.yaml`
buildDist = pnpm2nix.mkPnpmPackage {
src = ./.;
Expand All @@ -84,5 +87,6 @@
${pkgs.static-web-server}/bin/static-web-server --root .
'';
});
*/
};
}

0 comments on commit df109da

Please sign in to comment.