Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pre-commit: rename and alias to git-hooks #1571

Merged
merged 7 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ jobs:
- name: Install devenv
run: nix profile install . -L --accept-flake-config

- name: Disable pre-commit hooks
- name: Disable git-hooks
run: |
echo '{ pre-commit.default_stages = ["manual"]; }' > devenv.local.nix
echo '{ git-hooks.default_stages = ["manual"]; }' > devenv.local.nix

- name: Generate doc options
run: devenv shell devenv-generate-doc-options
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ Running ``devenv init`` generates ``devenv.nix``:
# https://devenv.sh/services/
services.postgres.enable = true;

# https://devenv.sh/pre-commit-hooks/
pre-commit.hooks.shellcheck.enable = true;
# https://devenv.sh/git-hooks/
git-hooks.hooks.shellcheck.enable = true;

# https://devenv.sh/processes/
processes.ping.exec = "ping localhost";
Expand Down
1 change: 1 addition & 0 deletions _redirects
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/blog/2023/03/20/devenv-10-rewrite-in-rust/ /blog/2024/03/20/devenv-10-rewrite-in-rust/ 301
/blog/2024/10/22/devenv-is-switching-nix-implementation-to-tvix/ /blog/2024/10/22/devenv-is-switching-its-nix-implementation-to-tvix/ 301
/pre-commit-hooks/ /git-hooks/ 301
73 changes: 38 additions & 35 deletions devenv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
]
},
"locked": {
"lastModified": 1726153070,
"lastModified": 1730504689,
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "bcef6817a8b2aa20a5a6dbb19b43e63c5bf8619a",
"rev": "506278e768c2a08bec68eb62932193e341f55c90",
"type": "github"
},
"original": {
Expand All @@ -63,10 +63,32 @@
"type": "github"
}
},
"git-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1730302582,
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "af8a16fe5c264f5e9e18bcee2859b40a656876cf",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"git-hooks",
"nixpkgs"
]
},
Expand All @@ -86,10 +108,10 @@
"libgit2": {
"flake": false,
"locked": {
"lastModified": 1727433268,
"lastModified": 1730231647,
"owner": "libgit2",
"repo": "libgit2",
"rev": "d82310318da2137ec88ca2e2b2bca962e111db71",
"rev": "c6111ec06cc0b0126cd67bdab78f8091e4cfaa10",
"type": "github"
},
"original": {
Expand All @@ -100,7 +122,7 @@
},
"nix": {
"inputs": {
"flake-compat": "flake-compat",
"flake-compat": "flake-compat_2",
"flake-parts": "flake-parts",
"libgit2": "libgit2",
"nixpkgs": "nixpkgs",
Expand All @@ -124,10 +146,10 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1727435427,
"lastModified": 1730665687,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9a33680635c55945d01d0b7929beff1356546fe5",
"rev": "df9782b6077321330159a0ad8902d879f093d7c1",
"type": "github"
},
"original": {
Expand Down Expand Up @@ -169,10 +191,10 @@
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1727264057,
"lastModified": 1730327045,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "759537f06e6999e141588ff1c9be7f3a5c060106",
"rev": "080166c15633801df010977d9d7474b4a6c549d7",
"type": "github"
},
"original": {
Expand Down Expand Up @@ -215,32 +237,10 @@
]
},
"locked": {
"lastModified": 1726745158,
"lastModified": 1730302582,
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "4e743a6920eab45e8ba0fbe49dc459f1423a4b74",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"pre-commit-hooks_2": {
"inputs": {
"flake-compat": "flake-compat_2",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1726745158,
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "4e743a6920eab45e8ba0fbe49dc459f1423a4b74",
"rev": "af8a16fe5c264f5e9e18bcee2859b40a656876cf",
"type": "github"
},
"original": {
Expand All @@ -252,9 +252,12 @@
"root": {
"inputs": {
"devenv": "devenv",
"git-hooks": "git-hooks",
"nix": "nix",
"nixpkgs": "nixpkgs_2",
"pre-commit-hooks": "pre-commit-hooks_2"
"pre-commit-hooks": [
"git-hooks"
]
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions devenv/init/devenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
git --version | grep --color=auto "${pkgs.git.version}"
'';

# https://devenv.sh/pre-commit-hooks/
# pre-commit.hooks.shellcheck.enable = true;
# https://devenv.sh/git-hooks/
# git-hooks.hooks.shellcheck.enable = true;

# See full reference at https://devenv.sh/reference/options/
}
5 changes: 3 additions & 2 deletions devenv/src/flake.tmpl.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
let
__DEVENV_VARS__
in {
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
git-hooks.url = "github:cachix/git-hooks.nix";
git-hooks.inputs.nixpkgs.follows = "nixpkgs";
pre-commit-hooks.follows = "git-hooks";
nixpkgs.url = "github:cachix/devenv-nixpkgs/rolling";
devenv.url = "github:cachix/devenv?dir=src/modules";
} // (if builtins.pathExists (devenv_dotfile + "/flake.json")
Expand Down
4 changes: 2 additions & 2 deletions docs/guides/using-with-flakes.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ And run [tests with `devenv test`](/tests).
```console
$ devenv test
Running tasks devenv:enterShell
Succeeded devenv:pre-commit:install 10ms
Succeeded devenv:git-hooks:install 10ms
Succeeded devenv:enterShell 4ms
2 Succeeded 14.75ms
• Testing ...
Running tasks devenv:enterTest
Succeeded devenv:pre-commit:run 474ms
Succeeded devenv:git-hooks:run 474ms
Not implemented devenv:enterTest
1 Skipped, 1 Succeeded 474.62ms
```
Expand Down
4 changes: 2 additions & 2 deletions docs/inputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ If you omit `devenv.yaml`, it defaults to:
inputs:
nixpkgs:
url: github:cachix/devenv-nixpkgs/rolling
pre-commit-hooks:
url: github:cachix/pre-commit-hooks.nix
git-hooks:
url: github:cachix/git-hooks.nix
```

The dependencies you mention as `inputs` are passed as an argument to the function.
Expand Down
4 changes: 2 additions & 2 deletions docs/integrations/github-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ you can pre-install both Nix and devenv, and skip the associated steps.
### `devenv test`

Devenv provides a convenient built-in `devenv test` command.
It builds the shell and runs any defined [pre-commit hooks](../pre-commit-hooks.md) against your repository.
It builds the shell and runs any defined [git hooks](../git-hooks.md) against your repository.
This is a quick and easy way to test that your development environment works as expected and lint your code at the same time.

```yaml
- name: Build the devenv shell and run any pre-commit hooks
- name: Build the devenv shell and run any git hooks
run: devenv test
```

Expand Down
8 changes: 4 additions & 4 deletions docs/overrides/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h1 class="text-2xl font-bold tracking-tight text-black sm:text-4xl">Fast, Decla
• Define <a href="/processes" class="text-[#425C82] font-medium">processes</a>
• Reuse <a href="/services" class="text-[#425C82] font-medium">services</a>
• Run <a href="/tests" class="text-[#425C82] font-medium">tests</a>
• Enforce <a href="/pre-commit-hooks" class="text-[#425C82] font-medium">git hooks</a>
• Enforce <a href="/git-hooks" class="text-[#425C82] font-medium">git hooks</a>
</p>
<div class="mt-10 flex items-center justify-center gap-x-6">
<a href="/getting-started/"
Expand Down Expand Up @@ -165,7 +165,7 @@ <h1 class="text-2xl font-bold tracking-tight text-black sm:text-4xl">Fast, Decla
};

# Runs on `git commit` and `devenv test`
pre-commit.hooks = {
git-hooks.hooks = {
black.enable = true;
# Your custom hooks
generate-css = {
Expand All @@ -183,7 +183,7 @@ <h1 class="text-2xl font-bold tracking-tight text-black sm:text-4xl">Fast, Decla
<pre class="text-white text-sm"><code class="language-shell" data-shell-prefix="$">devenv shell
...
Running tasks devenv:enterShell
Succeeded devenv:pre-commit:install 15ms
Succeeded devenv:git-hooks:install 15ms
Succeeded myapp:build 23ms
Succeeded devenv:enterShell 23ms
3 Succeeded 50.14ms
Expand All @@ -199,7 +199,7 @@ <h1 class="text-2xl font-bold tracking-tight text-black sm:text-4xl">Fast, Decla
<p class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">Scripts and Tasks</p>
<p class="mt-6 text-xl font-medium leading-8 text-gray-600">
Define <a href="/scripts/" class="text-[#425C82] font-semibold">scripts</a>, <a href="/tasks/" class="text-[#425C82] font-semibold">tasks</a> and
<a href="/pre-commit-hooks/" class="text-[#425C82] font-semibold">git hooks</a>
<a href="/git-hooks/" class="text-[#425C82] font-semibold">git hooks</a>
to automate your development workflow.
<dl class="mt-10 max-w-xl space-y-8 text-base leading-7 text-gray-600 lg:max-w-none">
<div class="relative lg:pl-3">
Expand Down
12 changes: 6 additions & 6 deletions docs/pre-commit-hooks.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
``devenv`` has first-class integration for [pre-commit](https://pre-commit.com/) via [pre-commit-hooks.nix](https://github.com/cachix/pre-commit-hooks.nix).
``devenv`` has first-class integration for [pre-commit](https://pre-commit.com/) via [git-hooks.nix](https://github.com/cachix/git-hooks.nix).

## Set up

Expand All @@ -10,7 +10,7 @@ We recommend a two-step approach for integrating your linters and formatters.
{ inputs, ... }:

{
pre-commit.hooks = {
git-hooks.hooks = {
# lint shell scripts
shellcheck.enable = true;
# execute example shell from Markdown files
Expand All @@ -21,11 +21,11 @@ We recommend a two-step approach for integrating your linters and formatters.
# override a package with a different version
ormolu.enable = true;
ormolu.package = pkgs.haskellPackages.ormolu;

# some hooks have more than one package, like clippy:
clippy.enable = true;
clippy.packageOverrides.cargo = pkgs.cargo;
clippy.packageOverrides.clippy = tools.clippy;
clippy.packageOverrides.clippy = pkgs.clippy;
# some hooks provide settings
clippy.settings.allFeatures = true;
};
Expand Down Expand Up @@ -63,7 +63,7 @@ If you'd like to define your own hook you can do:

```nix title="devenv.nix"
{
pre-commit.hooks.unit-tests = {
git-hooks.hooks.unit-tests = {
enable = true;

# The name of the hook (appears on the report table):
Expand Down Expand Up @@ -94,4 +94,4 @@ If you'd like to define your own hook you can do:
pass_filenames = false;
};
}
```
```
Loading
Loading