From a130d70f832e59799a2e86c1f8ff063b0fef9daa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Reynier?= Date: Tue, 26 Mar 2024 13:37:51 +0000 Subject: [PATCH 1/5] Fix typos and add pre-commit check --- .typos.toml | 3 +++ modules/hook.nix | 2 +- modules/hooks.nix | 8 ++++---- nix/default.nix | 1 + 4 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 .typos.toml diff --git a/.typos.toml b/.typos.toml new file mode 100644 index 00000000..60efd63e --- /dev/null +++ b/.typos.toml @@ -0,0 +1,3 @@ +[default.extend-words] +edn = "edn" # `cljfmt` option +mosquitto = "mosquitto" # `typos` example diff --git a/modules/hook.nix b/modules/hook.nix index 3c353e46..d6195893 100644 --- a/modules/hook.nix +++ b/modules/hook.nix @@ -50,7 +50,7 @@ in '' An optional package that provides the hook. - For most hooks, the package name matches the name of the hook and can be overriden directly. + For most hooks, the package name matches the name of the hook and can be overridden directly. ``` hooks.nixfmt.package = pkgs.nixfmt; diff --git a/modules/hooks.nix b/modules/hooks.nix index 70b99009..0805ceba 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -1450,14 +1450,14 @@ in quiet = mkOption { type = types.bool; - description = lib.mdDoc "Less output per occurence."; + description = lib.mdDoc "Less output per occurrence."; default = false; }; verbose = mkOption { type = types.bool; - description = lib.mdDoc "More output per occurence."; + description = lib.mdDoc "More output per occurrence."; default = false; }; @@ -2301,7 +2301,7 @@ in }; lychee = { name = "lychee"; - 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."; + 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."; package = tools.lychee; entry = let @@ -2925,7 +2925,7 @@ in package = tools.vale; entry = let - # TODO: was .vale.ini, throwed error in Nix + # TODO: was .vale.ini, threw error in Nix configFile = builtins.toFile "vale.ini" "${hooks.vale.settings.config}"; cmdArgs = mkCmdArgs diff --git a/nix/default.nix b/nix/default.nix index edbb0924..26b6a6a4 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -23,6 +23,7 @@ let hooks = { shellcheck.enable = true; nixpkgs-fmt.enable = true; + typos.enable = true; }; }; all-tools-eval = From 6c48d19a93ed6891c6d99cdcc1f712917a763622 Mon Sep 17 00:00:00 2001 From: Daniel Sampliner Date: Fri, 29 Mar 2024 12:22:45 -0400 Subject: [PATCH 2/5] Silence git default branch warning --- modules/pre-commit.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/pre-commit.nix b/modules/pre-commit.nix index 54e1fe16..12b769cf 100644 --- a/modules/pre-commit.nix +++ b/modules/pre-commit.nix @@ -64,7 +64,7 @@ let ln -fs ${configFile} src/.pre-commit-config.yaml cd src rm -rf .git - git init + git init -q git add . git config --global user.email "you@example.com" git config --global user.name "Your Name" From dc6812ea2c8a21cca091ecb9ae0433d89e03efe4 Mon Sep 17 00:00:00 2001 From: Daniel Sampliner Date: Fri, 29 Mar 2024 12:24:43 -0400 Subject: [PATCH 3/5] Silence git commit summary --- modules/pre-commit.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/pre-commit.nix b/modules/pre-commit.nix index 12b769cf..4b0df75c 100644 --- a/modules/pre-commit.nix +++ b/modules/pre-commit.nix @@ -68,7 +68,7 @@ let git add . git config --global user.email "you@example.com" git config --global user.name "Your Name" - git commit -m "init" + git commit -m "init" -q if [[ ${toString (compare install_stages [ "manual" ])} -eq 0 ]] then echo "Running: $ pre-commit run --hook-stage manual --all-files" From 5da7bab7c34586b8a0a8c397d8c6b257fcceb96e Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Fri, 29 Mar 2024 10:28:15 -0700 Subject: [PATCH 4/5] Fix `nix flake check` on macOS --- flake.nix | 4 +++- modules/hooks.nix | 3 ++- nix/default.nix | 13 ++++++++----- nix/headache/default.nix | 11 +++++++++-- nix/tools.nix | 14 ++++---------- 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/flake.nix b/flake.nix index bcc064cd..b789f70c 100644 --- a/flake.nix +++ b/flake.nix @@ -48,7 +48,9 @@ }; checks = lib.filterAttrs (k: v: v != null) - (exposed.checks // exposed-stable.checks); + (exposed.checks + // (lib.mapAttrs' (name: value: lib.nameValuePair "stable-${name}" value) + exposed-stable.checks)); lib = { inherit (exposed) run; }; } diff --git a/modules/hooks.nix b/modules/hooks.nix index 021a5f4e..37df4e95 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -1580,6 +1580,7 @@ in { name = "ansible-lint"; description = "Ansible linter"; + package = tools.ansible-lint; entry = let cmdArgs = @@ -1587,7 +1588,7 @@ in [ (hooks.ansible-lint.settings.configPath != "") "-c ${hooks.ansible-lint.settings.configPath}" ] ]; in - "${tools.ansible-lint}/bin/ansible-lint ${cmdArgs}"; + "${hooks.ansible-lint.package}/bin/ansible-lint ${cmdArgs}"; files = if hooks.ansible-lint.settings.subdir != "" then "${hooks.ansible-lint.settings.subdir}/" else ""; }; autoflake = diff --git a/nix/default.nix b/nix/default.nix index edbb0924..b4d08614 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -7,13 +7,14 @@ let overlay = self: pkgs: let + inherit (pkgs) lib; tools = import ./call-tools.nix pkgs; run = pkgs.callPackage ./run.nix { inherit pkgs tools isFlakes gitignore-nix-src; }; in { inherit tools run; # Flake style attributes - packages = tools // { + packages = (lib.filterAttrs (_name: value: value != null) tools) // { inherit (pkgs) pre-commit; }; checks = self.packages // { @@ -27,7 +28,7 @@ let }; all-tools-eval = let - config = pkgs.lib.evalModules { + config = lib.evalModules { modules = [ ../modules/all-modules.nix { @@ -37,7 +38,10 @@ let specialArgs = { inherit pkgs; }; }; allHooks = config.config.hooks; - allEntryPoints = pkgs.lib.mapAttrsToList (_: v: v.entry) allHooks; + allEntryPoints = lib.pipe allHooks [ + (lib.filterAttrs (_name: value: value.package != null)) + (lib.mapAttrsToList (_: value: value.entry)) + ]; in pkgs.runCommand "all-tools-eval" { @@ -47,7 +51,6 @@ let ''; doc-check = let - inherit (pkgs) lib; # We might add that it keeps rendering fast and robust, # and we want to teach `defaultText` which is more broadly applicable, # but the message is long enough. @@ -64,7 +67,7 @@ let If necessary, you can also find the offending option by evaluating with `--show-trace` and then look for occurrences of `option`. ''; pkgsStub = lib.mapAttrs failPkgAttr pkgs; - configuration = pkgs.lib.evalModules { + configuration = lib.evalModules { modules = [ ../modules/all-modules.nix { diff --git a/nix/headache/default.nix b/nix/headache/default.nix index 014832da..d7a4c1cd 100644 --- a/nix/headache/default.nix +++ b/nix/headache/default.nix @@ -1,9 +1,16 @@ -{ stdenv, lib, headache ? null, ocamlPackages }: +{ stdenv, lib, darwin, headache ? null, ocamlPackages }: ## NOTE: `headache` moved from `ocamlPackages.headache` to top-level on 8 June ## 2023. Once this gets into a NixOS release, the following code will be ## useless. -let the-headache = if headache != null then headache else ocamlPackages.headache; in +let + the-headache = + (if headache != null then headache else ocamlPackages.headache).overrideAttrs (drv: { + nativeBuildInputs = (drv.nativeBuildInputs or [ ]) ++ lib.optionals stdenv.isDarwin [ + darwin.sigtool + ]; + }); +in ## NOTE: The following derivation seems rather trivial, but it is used here to ## get rid of a runtime dependency in the whole OCaml compiler (~420M). diff --git a/nix/tools.nix b/nix/tools.nix index a84af0df..b8346115 100644 --- a/nix/tools.nix +++ b/nix/tools.nix @@ -1,4 +1,5 @@ { stdenv +, lib , actionlint , alejandra @@ -26,18 +27,14 @@ , elixir , elmPackages , fprettify -, git , git-annex -, gitAndTools , gptcommit ? null , hadolint -, haskell , haskellPackages , hindent , hlint , hpack , html-tidy -, hunspell , luaPackages , lua-language-server , lychee @@ -57,7 +54,6 @@ , php82Packages , ripsecrets ? null , ruff ? null -, runCommand , rustfmt , shellcheck , bats @@ -69,15 +65,12 @@ , tagref , taplo , texlive -, tflint , topiary ? null ## Added in nixpkgs on Dec 2, 2022 , treefmt , typos , typstfmt , zprint , yamllint -, writeScript -, writeText , go , go-tools , golangci-lint @@ -115,7 +108,6 @@ in editorconfig-checker elixir fprettify - git-annex go go-tools golangci-lint @@ -132,7 +124,6 @@ in nil nixfmt nixpkgs-fmt - opam ormolu pre-commit-hook-ensure-sops revive @@ -183,6 +174,9 @@ in chktex = tex; commitizen = commitizen.overrideAttrs (_: _: { doCheck = false; }); bats = if bats ? withLibraries then (bats.withLibraries (p: [ p.bats-support p.bats-assert p.bats-file ])) else bats; + git-annex = if stdenv.isDarwin then null else git-annex; + # Note: Only broken in stable nixpkgs, works fine on latest master. + opam = if stdenv.isDarwin then null else opam; ## NOTE: `checkmake` 0.2.2 landed in nixpkgs on 12 April 2023. Once this gets ## into a NixOS release, the following code will be useless. From 0d676ca9ca9df7f2d4d5fb0de511fed3a4b67fdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Sat, 30 Mar 2024 00:58:11 +0000 Subject: [PATCH 5/5] free up space on ci --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 58b41053..4c6935a4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,6 +15,7 @@ jobs: with: name: pre-commit-hooks signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' + - run: rm -rf /opt& - run: nix-build --keep-going tests-flakes: strategy: @@ -28,5 +29,6 @@ jobs: with: name: pre-commit-hooks signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' + - run: rm -rf /opt& - run: nix flake check --show-trace - run: nix eval .#lib.x86_64-linux.run --show-trace