Skip to content

Commit ea9ebd2

Browse files
committed
Merge remote-tracking branch 'upstream/master' into extend-yamllint-hook
2 parents 34fdf24 + c11e43a commit ea9ebd2

File tree

9 files changed

+40
-26
lines changed

9 files changed

+40
-26
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
with:
1616
name: pre-commit-hooks
1717
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
18+
- run: rm -rf /opt&
1819
- run: nix-build --keep-going
1920
tests-flakes:
2021
strategy:
@@ -28,5 +29,6 @@ jobs:
2829
with:
2930
name: pre-commit-hooks
3031
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
32+
- run: rm -rf /opt&
3133
- run: nix flake check --show-trace
3234
- run: nix eval .#lib.x86_64-linux.run --show-trace

.typos.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[default.extend-words]
2+
edn = "edn" # `cljfmt` option
3+
mosquitto = "mosquitto" # `typos` example

flake.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@
4848
};
4949

5050
checks = lib.filterAttrs (k: v: v != null)
51-
(exposed.checks // exposed-stable.checks);
51+
(exposed.checks
52+
// (lib.mapAttrs' (name: value: lib.nameValuePair "stable-${name}" value)
53+
exposed-stable.checks));
5254

5355
lib = { inherit (exposed) run; };
5456
}

modules/hook.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ in
5050
''
5151
An optional package that provides the hook.
5252
53-
For most hooks, the package name matches the name of the hook and can be overriden directly.
53+
For most hooks, the package name matches the name of the hook and can be overridden directly.
5454
5555
```
5656
hooks.nixfmt.package = pkgs.nixfmt;

modules/hooks.nix

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,14 +1475,14 @@ in
14751475
quiet =
14761476
mkOption {
14771477
type = types.bool;
1478-
description = lib.mdDoc "Less output per occurence.";
1478+
description = lib.mdDoc "Less output per occurrence.";
14791479
default = false;
14801480
};
14811481

14821482
verbose =
14831483
mkOption {
14841484
type = types.bool;
1485-
description = lib.mdDoc "More output per occurence.";
1485+
description = lib.mdDoc "More output per occurrence.";
14861486
default = false;
14871487
};
14881488

@@ -1625,14 +1625,15 @@ in
16251625
{
16261626
name = "ansible-lint";
16271627
description = "Ansible linter";
1628+
package = tools.ansible-lint;
16281629
entry =
16291630
let
16301631
cmdArgs =
16311632
mkCmdArgs [
16321633
[ (hooks.ansible-lint.settings.configPath != "") "-c ${hooks.ansible-lint.settings.configPath}" ]
16331634
];
16341635
in
1635-
"${tools.ansible-lint}/bin/ansible-lint ${cmdArgs}";
1636+
"${hooks.ansible-lint.package}/bin/ansible-lint ${cmdArgs}";
16361637
files = if hooks.ansible-lint.settings.subdir != "" then "${hooks.ansible-lint.settings.subdir}/" else "";
16371638
};
16381639
autoflake =
@@ -2360,7 +2361,7 @@ in
23602361
};
23612362
lychee = {
23622363
name = "lychee";
2363-
description = "A fast, async, stream-based link checker that finds broken hyperlinks and mail adresses inside Markdown, HTML, reStructuredText, or any other text file or website.";
2364+
description = "A fast, async, stream-based link checker that finds broken hyperlinks and mail addresses inside Markdown, HTML, reStructuredText, or any other text file or website.";
23642365
package = tools.lychee;
23652366
entry =
23662367
let
@@ -3004,7 +3005,8 @@ in
30043005
package = tools.vale;
30053006
entry =
30063007
let
3007-
configFile = builtins.toFile ".vale.ini" "${hooks.vale.settings.configuration}";
3008+
# TODO: was .vale.ini, threw error in Nix
3009+
configFile = builtins.toFile "vale.ini" "${hooks.vale.settings.config}";
30083010
cmdArgs =
30093011
mkCmdArgs
30103012
(with hooks.vale.settings; [

modules/pre-commit.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ let
6464
ln -fs ${configFile} src/.pre-commit-config.yaml
6565
cd src
6666
rm -rf .git
67-
git init
67+
git init -q
6868
git add .
6969
git config --global user.email "you@example.com"
7070
git config --global user.name "Your Name"
71-
git commit -m "init"
71+
git commit -m "init" -q
7272
if [[ ${toString (compare install_stages [ "manual" ])} -eq 0 ]]
7373
then
7474
echo "Running: $ pre-commit run --hook-stage manual --all-files"

nix/default.nix

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ let
77
overlay =
88
self: pkgs:
99
let
10+
inherit (pkgs) lib;
1011
tools = import ./call-tools.nix pkgs;
1112
run = pkgs.callPackage ./run.nix { inherit pkgs tools isFlakes gitignore-nix-src; };
1213
in
1314
{
1415
inherit tools run;
1516
# Flake style attributes
16-
packages = tools // {
17+
packages = (lib.filterAttrs (_name: value: value != null) tools) // {
1718
inherit (pkgs) pre-commit;
1819
};
1920
checks = self.packages // {
@@ -23,11 +24,12 @@ let
2324
hooks = {
2425
shellcheck.enable = true;
2526
nixpkgs-fmt.enable = true;
27+
typos.enable = true;
2628
};
2729
};
2830
all-tools-eval =
2931
let
30-
config = pkgs.lib.evalModules {
32+
config = lib.evalModules {
3133
modules = [
3234
../modules/all-modules.nix
3335
{
@@ -37,7 +39,10 @@ let
3739
specialArgs = { inherit pkgs; };
3840
};
3941
allHooks = config.config.hooks;
40-
allEntryPoints = pkgs.lib.mapAttrsToList (_: v: v.entry) allHooks;
42+
allEntryPoints = lib.pipe allHooks [
43+
(lib.filterAttrs (_name: value: value.package != null))
44+
(lib.mapAttrsToList (_: value: value.entry))
45+
];
4146
in
4247
pkgs.runCommand "all-tools-eval"
4348
{
@@ -47,7 +52,6 @@ let
4752
'';
4853
doc-check =
4954
let
50-
inherit (pkgs) lib;
5155
# We might add that it keeps rendering fast and robust,
5256
# and we want to teach `defaultText` which is more broadly applicable,
5357
# but the message is long enough.
@@ -64,7 +68,7 @@ let
6468
If necessary, you can also find the offending option by evaluating with `--show-trace` and then look for occurrences of `option`.
6569
'';
6670
pkgsStub = lib.mapAttrs failPkgAttr pkgs;
67-
configuration = pkgs.lib.evalModules {
71+
configuration = lib.evalModules {
6872
modules = [
6973
../modules/all-modules.nix
7074
{

nix/headache/default.nix

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
{ stdenv, lib, headache ? null, ocamlPackages }:
1+
{ stdenv, lib, darwin, headache ? null, ocamlPackages }:
22

33
## NOTE: `headache` moved from `ocamlPackages.headache` to top-level on 8 June
44
## 2023. Once this gets into a NixOS release, the following code will be
55
## useless.
6-
let the-headache = if headache != null then headache else ocamlPackages.headache; in
6+
let
7+
the-headache =
8+
(if headache != null then headache else ocamlPackages.headache).overrideAttrs (drv: {
9+
nativeBuildInputs = (drv.nativeBuildInputs or [ ]) ++ lib.optionals stdenv.isDarwin [
10+
darwin.sigtool
11+
];
12+
});
13+
in
714

815
## NOTE: The following derivation seems rather trivial, but it is used here to
916
## get rid of a runtime dependency in the whole OCaml compiler (~420M).

nix/tools.nix

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{ stdenv
2+
, lib
23

34
, actionlint
45
, alejandra
@@ -26,18 +27,14 @@
2627
, elixir
2728
, elmPackages
2829
, fprettify
29-
, git
3030
, git-annex
31-
, gitAndTools
3231
, gptcommit ? null
3332
, hadolint
34-
, haskell
3533
, haskellPackages
3634
, hindent
3735
, hlint
3836
, hpack
3937
, html-tidy
40-
, hunspell
4138
, luaPackages
4239
, lua-language-server
4340
, lychee
@@ -57,7 +54,6 @@
5754
, php82Packages
5855
, ripsecrets ? null
5956
, ruff ? null
60-
, runCommand
6157
, rustfmt
6258
, shellcheck
6359
, bats
@@ -69,15 +65,12 @@
6965
, tagref
7066
, taplo
7167
, texlive
72-
, tflint
7368
, topiary ? null ## Added in nixpkgs on Dec 2, 2022
7469
, treefmt
7570
, typos
7671
, typstfmt
7772
, zprint
7873
, yamllint
79-
, writeScript
80-
, writeText
8174
, go
8275
, go-tools
8376
, golangci-lint
@@ -115,7 +108,6 @@ in
115108
editorconfig-checker
116109
elixir
117110
fprettify
118-
git-annex
119111
go
120112
go-tools
121113
golangci-lint
@@ -132,7 +124,6 @@ in
132124
nil
133125
nixfmt
134126
nixpkgs-fmt
135-
opam
136127
ormolu
137128
pre-commit-hook-ensure-sops
138129
revive
@@ -183,6 +174,9 @@ in
183174
chktex = tex;
184175
commitizen = commitizen.overrideAttrs (_: _: { doCheck = false; });
185176
bats = if bats ? withLibraries then (bats.withLibraries (p: [ p.bats-support p.bats-assert p.bats-file ])) else bats;
177+
git-annex = if stdenv.isDarwin then null else git-annex;
178+
# Note: Only broken in stable nixpkgs, works fine on latest master.
179+
opam = if stdenv.isDarwin then null else opam;
186180

187181
## NOTE: `checkmake` 0.2.2 landed in nixpkgs on 12 April 2023. Once this gets
188182
## into a NixOS release, the following code will be useless.

0 commit comments

Comments
 (0)