|
2 | 2 | description = "Development environment for codetracer-ruby-recorder"; |
3 | 3 |
|
4 | 4 | inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; |
| 5 | + inputs.pre-commit-hooks.url = "github:cachix/git-hooks.nix"; |
5 | 6 |
|
6 | 7 | outputs = { |
7 | 8 | self, |
8 | 9 | nixpkgs, |
| 10 | + pre-commit-hooks, |
9 | 11 | }: let |
10 | 12 | systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"]; |
11 | 13 | forEachSystem = nixpkgs.lib.genAttrs systems; |
12 | 14 | in { |
| 15 | + checks = forEachSystem (system: { |
| 16 | + pre-commit-check = pre-commit-hooks.lib.${system}.run { |
| 17 | + src = ./.; |
| 18 | + hooks = { |
| 19 | + lint = { |
| 20 | + enable = true; |
| 21 | + name = "Lint"; |
| 22 | + entry = "just lint"; |
| 23 | + language = "system"; |
| 24 | + pass_filenames = false; |
| 25 | + }; |
| 26 | + }; |
| 27 | + }; |
| 28 | + }); |
| 29 | + |
13 | 30 | devShells = forEachSystem (system: let |
14 | | - pkgs = import nixpkgs {inherit system;}; |
| 31 | + pkgs = import nixpkgs { inherit system; }; |
| 32 | + preCommit = self.checks.${system}.pre-commit-check; |
15 | 33 | isLinux = pkgs.stdenv.isLinux; |
16 | 34 | isDarwin = pkgs.stdenv.isDarwin; |
17 | 35 | in { |
|
43 | 61 | # Required for Ruby C extension compilation on macOS |
44 | 62 | darwin.apple_sdk.frameworks.CoreFoundation |
45 | 63 | darwin.apple_sdk.frameworks.Security |
46 | | - ]; |
| 64 | + ] ++ preCommit.enabledPackages; |
47 | 65 |
|
48 | 66 | # Environment variables required to fix build issues with rb-sys/bindgen |
49 | 67 |
|
|
56 | 74 | CLANG_PATH = "${pkgs.llvmPackages.clang}/bin/clang"; |
57 | 75 | CC = "${pkgs.llvmPackages.clang}/bin/clang"; |
58 | 76 | CXX = "${pkgs.llvmPackages.clang}/bin/clang++"; |
| 77 | + |
| 78 | + inherit (preCommit) shellHook; |
59 | 79 | } // pkgs.lib.optionalAttrs isLinux { |
60 | 80 | # BINDGEN_EXTRA_CLANG_ARGS: Additional clang arguments for bindgen when parsing Ruby headers |
61 | 81 | # Includes system header paths that are not automatically discovered in NixOS |
|
0 commit comments