Skip to content

Commit

Permalink
Merge pull request #488 from trueNAHO/docs-rename-pre-commit-hooks-ni…
Browse files Browse the repository at this point in the history
…x-repository-to-git-hooks-nix

docs: rename `pre-commit-hooks.nix` instances to `git-hooks.nix`
  • Loading branch information
domenkozar authored Aug 23, 2024
2 parents 6cedaa7 + c08fc07 commit c8a5405
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Given the following `flake.nix` example:
{
description = "An example project.";
inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
inputs.pre-commit-hooks.url = "github:cachix/git-hooks.nix";
outputs = { self, nixpkgs, ... }@inputs:
let
Expand Down Expand Up @@ -82,7 +82,7 @@ nix develop

```nix
let
nix-pre-commit-hooks = import (builtins.fetchTarball "https://github.com/cachix/pre-commit-hooks.nix/tarball/master");
nix-pre-commit-hooks = import (builtins.fetchTarball "https://github.com/cachix/git-hooks.nix/tarball/master");
in {
# Configured with the module options defined in `modules/pre-commit.nix`:
pre-commit-check = nix-pre-commit-hooks.run {
Expand Down Expand Up @@ -387,7 +387,7 @@ Example configuration:

```nix
let
nix-pre-commit-hooks = import (builtins.fetchTarball "https://github.com/cachix/pre-commit-hooks.nix/tarball/master");
nix-pre-commit-hooks = import (builtins.fetchTarball "https://github.com/cachix/git-hooks.nix/tarball/master");
in {
pre-commit-check = nix-pre-commit-hooks.run {
hooks = {
Expand Down
2 changes: 1 addition & 1 deletion flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ in
};
default = { };
description = ''
The pre-commit-hooks.nix configuration.
The git-hooks.nix configuration.
'';
};
installationScript = mkOption {
Expand Down
14 changes: 7 additions & 7 deletions modules/hooks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,7 @@ in
## this gets into a NixOS release, the following code will be useless.
lib.throwIf
(hooks.checkmake.package == null)
"The version of nixpkgs used by pre-commit-hooks.nix must have `checkmake` in version at least 0.2.2 for it to work on non-Linux systems."
"The version of nixpkgs used by git-hooks.nix must have `checkmake` in version at least 0.2.2 for it to work on non-Linux systems."
"${hooks.checkmake.package}/bin/checkmake";
};
check-added-large-files =
Expand Down Expand Up @@ -2096,7 +2096,7 @@ in
# need version >= 0.4.0 for the --from-stdin flag
toolVersionCheck = lib.versionAtLeast convco.version "0.4.0";
in
lib.throwIf (convco == null || !toolVersionCheck) "The version of Nixpkgs used by pre-commit-hooks.nix does not have the `convco` package (>=0.4.0). Please use a more recent version of Nixpkgs."
lib.throwIf (convco == null || !toolVersionCheck) "The version of Nixpkgs used by git-hooks.nix does not have the `convco` package (>=0.4.0). Please use a more recent version of Nixpkgs."
builtins.toString
script;
stages = [ "commit-msg" ];
Expand Down Expand Up @@ -2521,7 +2521,7 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
"$PRE_COMMIT_COMMIT_MSG_SOURCE" --commit-msg-file "$1"
'';
in
lib.throwIf (hooks.gptcommit.package == null) "The version of Nixpkgs used by pre-commit-hooks.nix does not have the `gptcommit` package. Please use a more recent version of Nixpkgs."
lib.throwIf (hooks.gptcommit.package == null) "The version of Nixpkgs used by git-hooks.nix does not have the `gptcommit` package. Please use a more recent version of Nixpkgs."
toString
script;
stages = [ "prepare-commit-msg" ];
Expand All @@ -2547,7 +2547,7 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
## next NixOS release, the following code will become irrelevant.
lib.throwIf
(hooks.headache.package == null)
"The version of nixpkgs used by pre-commit-hooks.nix does not have `ocamlPackages.headache`. Please use a more recent version of nixpkgs."
"The version of nixpkgs used by git-hooks.nix does not have `ocamlPackages.headache`. Please use a more recent version of nixpkgs."
"${hooks.headache.package}/bin/headache -h ${hooks.headache.settings.header-file}";
};
hindent =
Expand Down Expand Up @@ -3002,7 +3002,7 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
## useless.
lib.throwIf
(hooks.pre-commit-hook-ensure-sops.package == 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."
"The version of nixpkgs used by git-hooks.nix does not have the `pre-commit-hook-ensure-sops` package. Please use a more recent version of nixpkgs."
''
${hooks.pre-commit-hook-ensure-sops.package}/bin/pre-commit-hook-ensure-sops
'';
Expand Down Expand Up @@ -3401,7 +3401,7 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
## useless.
lib.throwIf
(hooks.topiary.package == null)
"The version of nixpkgs used by pre-commit-hooks.nix does not have the `topiary` package. Please use a more recent version of nixpkgs."
"The version of nixpkgs used by git-hooks.nix does not have the `topiary` package. Please use a more recent version of nixpkgs."
(
let
topiary-inplace = pkgs.writeShellApplication {
Expand Down Expand Up @@ -3498,7 +3498,7 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
entry =
lib.throwIf
(hooks.typstyle.package == null)
"The version of nixpkgs used by pre-commit-hooks.nix must contain typstyle"
"The version of nixpkgs used by git-hooks.nix must contain typstyle"
"${hooks.typstyle.package}/bin/typstyle -i";
files = "\\.typ$";
};
Expand Down
16 changes: 8 additions & 8 deletions modules/pre-commit.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ let
} ''
{
echo '# DO NOT MODIFY';
echo '# This file was generated by pre-commit-hooks.nix';
echo '# This file was generated by git-hooks.nix';
jq . <"$rawJSONPath"
} >$out
''
Expand Down Expand Up @@ -126,7 +126,7 @@ in
`nix-pre-commit-hooks` comes with its own set of packages for this purpose.
'';
defaultText =
lib.literalExpression or literalExample ''pre-commit-hooks.nix-pkgs.callPackage tools-dot-nix { inherit (pkgs) system; }'';
lib.literalExpression or literalExample ''git-hooks.nix-pkgs.callPackage tools-dot-nix { inherit (pkgs) system; }'';
};

enabledPackages = mkOption {
Expand Down Expand Up @@ -329,9 +329,9 @@ in
export PATH=${cfg.package}/bin:$PATH
if ! type -t git >/dev/null; then
# This happens in pure shells, including lorri
echo 1>&2 "WARNING: pre-commit-hooks.nix: git command not found; skipping installation."
echo 1>&2 "WARNING: git-hooks.nix: git command not found; skipping installation."
elif ! ${git}/bin/git rev-parse --git-dir &> /dev/null; then
echo 1>&2 "WARNING: pre-commit-hooks.nix: .git not found; skipping installation."
echo 1>&2 "WARNING: git-hooks.nix: .git not found; skipping installation."
else
GIT_WC=`${git}/bin/git rev-parse --show-toplevel`
Expand All @@ -341,13 +341,13 @@ in
if ! readlink "''${GIT_WC}/.pre-commit-config.yaml" >/dev/null \
|| [[ $(readlink "''${GIT_WC}/.pre-commit-config.yaml") != ${configFile} ]]; then
echo 1>&2 "pre-commit-hooks.nix: updating $PWD repo"
echo 1>&2 "git-hooks.nix: updating $PWD repo"
[ -L .pre-commit-config.yaml ] && unlink .pre-commit-config.yaml
if [ -e "''${GIT_WC}/.pre-commit-config.yaml" ]; then
echo 1>&2 "pre-commit-hooks.nix: WARNING: Refusing to install because of pre-existing .pre-commit-config.yaml"
echo 1>&2 "git-hooks.nix: WARNING: Refusing to install because of pre-existing .pre-commit-config.yaml"
echo 1>&2 " 1. Translate .pre-commit-config.yaml contents to the new syntax in your Nix file"
echo 1>&2 " see https://github.com/cachix/pre-commit-hooks.nix#getting-started"
echo 1>&2 " see https://github.com/cachix/git-hooks.nix#getting-started"
echo 1>&2 " 2. remove .pre-commit-config.yaml"
echo 1>&2 " 3. add .pre-commit-config.yaml to .gitignore"
else
Expand All @@ -373,7 +373,7 @@ in
pre-commit install -t $stage
;;
*)
echo 1>&2 "ERROR: pre-commit-hooks.nix: either $stage is not a valid stage or pre-commit-hooks.nix doesn't yet support it."
echo 1>&2 "ERROR: git-hooks.nix: either $stage is not a valid stage or git-hooks.nix doesn't yet support it."
exit 1
;;
esac
Expand Down
6 changes: 3 additions & 3 deletions template/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
git-hooks-nix.inputs.nixpkgs.follows = "nixpkgs";
git-hooks-nix.url = "github:cachix/git-hooks.nix";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
pre-commit-hooks-nix.url = "github:cachix/pre-commit-hooks.nix";
pre-commit-hooks-nix.inputs.nixpkgs.follows = "nixpkgs";
};

outputs = inputs@{ self, flake-parts, ... }:
flake-parts.lib.mkFlake
{ inherit inputs; }
{
imports = [
inputs.pre-commit-hooks-nix.flakeModule
inputs.git-hooks-nix.flakeModule
];
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
perSystem = { config, self', inputs', pkgs, ... }: {
Expand Down

0 comments on commit c8a5405

Please sign in to comment.