From e6df60debbf654307739e5bf0c6f1b20b9b9e36f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 14 Jan 2024 09:51:15 +0100 Subject: [PATCH] make pre-commit-hooks-nix optional MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This dependency brings in a lot of other dependencies including a nixpkgs copy. By making it optional in the flake users can disable it in their own flake. After removing the dependency, the following inputs are no longer needed: • Removed input 'pre-commit-hooks-nix' • Removed input 'pre-commit-hooks-nix/flake-compat' • Removed input 'pre-commit-hooks-nix/flake-utils' • Removed input 'pre-commit-hooks-nix/gitignore' • Removed input 'pre-commit-hooks-nix/gitignore/nixpkgs' • Removed input 'pre-commit-hooks-nix/nixpkgs' • Removed input 'pre-commit-hooks-nix/nixpkgs-stable' --- flake.nix | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/flake.nix b/flake.nix index 08652be..8c52611 100644 --- a/flake.nix +++ b/flake.nix @@ -7,6 +7,8 @@ flake-parts.url = "github:hercules-ci/flake-parts"; 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 = { url = "github:cachix/pre-commit-hooks.nix"; inputs.nixpkgs.follows = "nixpkgs"; @@ -55,9 +57,8 @@ # Derive the output overlay automatically from all packages that we define. inputs.flake-parts.flakeModules.easyOverlay - # Formatting and quality checks. - inputs.pre-commit-hooks-nix.flakeModule - ]; + # Formatting and quality checks. + ] ++ (if inputs.pre-commit-hooks-nix ? flakeModule then [ inputs.pre-commit-hooks-nix.flakeModule ] else [ ]); flake.nixosModules.lanzaboote = moduleWithSystem ( perSystem@{ config }: @@ -232,15 +233,6 @@ ukiModule = self.nixosModules.uki; }); - pre-commit = { - check.enable = true; - - settings.hooks = { - nixpkgs-fmt.enable = true; - typos.enable = true; - }; - }; - devShells.default = pkgs.mkShell { shellHook = '' ${config.pre-commit.installationScript} @@ -268,6 +260,15 @@ 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; + }; + }; }; })); }