refactor(nix): switch to flake-parts

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
Sefa Eyeoglu 2023-10-11 14:41:49 +02:00
parent e8f2149dd1
commit 7ab1002485
No known key found for this signature in database
GPG key ID: E13DFD4B47127951
3 changed files with 76 additions and 30 deletions

View file

@ -3,39 +3,50 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
flake-parts.url = "github:hercules-ci/flake-parts";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs = {
self,
nixpkgs,
flake-utils,
flake-parts,
pre-commit-hooks,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
alejandra.enable = true;
prettier = {
enable = true;
excludes = ["flake.lock" "pnpm-lock.yaml"];
};
} @ inputs:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
pre-commit-hooks.flakeModule
];
perSystem = {
config,
lib,
pkgs,
...
}: {
pre-commit.settings.hooks = {
alejandra.enable = true;
prettier = {
enable = true;
excludes = ["flake.lock" "pnpm-lock.yaml"];
};
};
devShells.default = pkgs.mkShell {
shellHook = ''
${config.pre-commit.installationScript}
'';
packages = with pkgs; [nodePackages.pnpm];
};
formatter = pkgs.alejandra;
};
devShells.default = pkgs.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
packages = with pkgs; [nodePackages.pnpm];
};
});
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
};
}