From af02198e564aba9d4b4f3cf4683c66daf21bcb1d Mon Sep 17 00:00:00 2001 From: nialov Date: Fri, 16 Dec 2022 21:00:42 +0200 Subject: [PATCH 1/2] Add pre-commit-hook-ensure-sops --- flake.lock | 6 +++--- modules/hooks.nix | 7 +++++++ nix/tools.nix | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index a815cf6c..e82100a5 100644 --- a/flake.lock +++ b/flake.lock @@ -56,11 +56,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1685866647, - "narHash": "sha256-4jKguNHY/edLYImB+uL8jKPL/vpfOvMmSlLAGfxSrnY=", + "lastModified": 1689261696, + "narHash": "sha256-LzfUtFs9MQRvIoQ3MfgSuipBVMXslMPH/vZ+nM40LkA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a53a3bec10deef6e1cc1caba5bc60f53b959b1e8", + "rev": "df1eee2aa65052a18121ed4971081576b25d6b5c", "type": "github" }, "original": { diff --git a/modules/hooks.nix b/modules/hooks.nix index b1d50aa8..5a122bc7 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -1016,6 +1016,13 @@ in "${binPath} ${lib.optionalString write "--write"} ${lib.optionalString (output != null) "--${output}"} --ignore-unknown"; types = [ "text" ]; }; + pre-commit-hook-ensure-sops = { + name = "pre-commit-hook-ensure-sops"; + entry = '' + ${tools.pre-commit-hook-ensure-sops}/bin/pre-commit-hook-ensure-sops + ''; + files = lib.mkDefault "^secrets"; + }; hunspell = { name = "hunspell"; diff --git a/nix/tools.nix b/nix/tools.nix index dcbd21e0..0fb48e77 100644 --- a/nix/tools.nix +++ b/nix/tools.nix @@ -41,6 +41,7 @@ , opam , ormolu , pkgsBuildBuild +, pre-commit-hook-ensure-sops , python39Packages , ruff ? null , runCommand @@ -100,6 +101,7 @@ in nixpkgs-fmt opam ormolu + pre-commit-hook-ensure-sops revive ruff rustfmt From f189105d2acf08f7719a4fe18cc347613fceedf3 Mon Sep 17 00:00:00 2001 From: nialov Date: Sun, 16 Jul 2023 14:26:07 +0300 Subject: [PATCH 2/2] Handle package missing from stable channel --- modules/hooks.nix | 13 ++++++++++--- nix/tools.nix | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/hooks.nix b/modules/hooks.nix index 5a122bc7..bbf14900 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -1018,9 +1018,16 @@ in }; pre-commit-hook-ensure-sops = { name = "pre-commit-hook-ensure-sops"; - entry = '' - ${tools.pre-commit-hook-ensure-sops}/bin/pre-commit-hook-ensure-sops - ''; + entry = + ## NOTE: pre-commit-hook-ensure-sops landed in nixpkgs on 8 July 2022. Once it reaches a + ## release of NixOS, the `throwIf` piece of code below will become + ## useless. + lib.throwIf + (tools.pre-commit-hook-ensure-sops == null) + "The version of nixpkgs used by pre-commit-hooks.nix does not have the `pre-commit-hook-ensure-sops` package. Please use a more recent version of nixpkgs." + '' + ${tools.pre-commit-hook-ensure-sops}/bin/pre-commit-hook-ensure-sops + ''; files = lib.mkDefault "^secrets"; }; hunspell = diff --git a/nix/tools.nix b/nix/tools.nix index 0fb48e77..3d935174 100644 --- a/nix/tools.nix +++ b/nix/tools.nix @@ -41,7 +41,7 @@ , opam , ormolu , pkgsBuildBuild -, pre-commit-hook-ensure-sops +, pre-commit-hook-ensure-sops ? null , python39Packages , ruff ? null , runCommand