Merge pull request #282 from nix-community/pre-commit-hooks-nix

make pre-commit-hooks-nix optional
This commit is contained in:
Ryan Lahfa 2024-01-15 17:03:58 +00:00 committed by GitHub
commit 60ad6f7051
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 12 deletions

View File

@ -7,6 +7,8 @@
flake-parts.url = "github:hercules-ci/flake-parts"; flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs"; flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
# Only used during development, can be disabled by flake users like this:
# lanzaboote.inputs.pre-commit-hooks-nix.follows = "";
pre-commit-hooks-nix = { pre-commit-hooks-nix = {
url = "github:cachix/pre-commit-hooks.nix"; url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
@ -55,9 +57,8 @@
# Derive the output overlay automatically from all packages that we define. # Derive the output overlay automatically from all packages that we define.
inputs.flake-parts.flakeModules.easyOverlay inputs.flake-parts.flakeModules.easyOverlay
# Formatting and quality checks. # Formatting and quality checks.
inputs.pre-commit-hooks-nix.flakeModule ] ++ (if inputs.pre-commit-hooks-nix ? flakeModule then [ inputs.pre-commit-hooks-nix.flakeModule ] else [ ]);
];
flake.nixosModules.lanzaboote = moduleWithSystem ( flake.nixosModules.lanzaboote = moduleWithSystem (
perSystem@{ config }: perSystem@{ config }:
@ -232,15 +233,6 @@
ukiModule = self.nixosModules.uki; ukiModule = self.nixosModules.uki;
}); });
pre-commit = {
check.enable = true;
settings.hooks = {
nixpkgs-fmt.enable = true;
typos.enable = true;
};
};
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
shellHook = '' shellHook = ''
${config.pre-commit.installationScript} ${config.pre-commit.installationScript}
@ -268,6 +260,15 @@
TEST_SYSTEMD = pkgs.systemd; TEST_SYSTEMD = pkgs.systemd;
}; };
} // lib.optionalAttrs (inputs.pre-commit-hooks-nix ? flakeModule) {
pre-commit = {
check.enable = true;
settings.hooks = {
nixpkgs-fmt.enable = true;
typos.enable = true;
};
};
}; };
})); }));
} }