Skip to content

Commit

Permalink
Merge pull request #391 from K900/fix-tools
Browse files Browse the repository at this point in the history
fix: fix up tools indirections, ensure the used tools actually exist
  • Loading branch information
domenkozar authored Jan 14, 2024
2 parents 274ae39 + 1e70292 commit ffa9a5b
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 44 deletions.
32 changes: 16 additions & 16 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
description = "Seamless integration of https://pre-commit.com git hooks with Nix.";

inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-23.05";
inputs.nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-23.11";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.flake-compat = {
url = "github:edolstra/flake-compat";
Expand Down
44 changes: 22 additions & 22 deletions modules/hooks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ in
mkOption {
type = types.str;
description = lib.mdDoc "flake8 binary path. Should be used to specify flake8 binary from your Nix-managed Python environment.";
default = "${tools.python39Packages.flake8}/bin/flake8";
default = "${tools.flake8}/bin/flake8";
defaultText = lib.literalExpression ''
"''${tools.python39Packages.flake8}/bin/flake8"
"''${tools.flake8}/bin/flake8"
'';
};
extendIgnore =
Expand Down Expand Up @@ -366,8 +366,8 @@ in
mkOption {
type = types.package;
description = lib.mdDoc "The `flynt` package to use.";
default = "${tools.python311Packages.flynt}";
defaultText = "\${pkgs.python311Packages.flynt}";
default = "${tools.flynt}";
defaultText = "\${tools.flynt}";
example = "\${pkgs.python310Packages.flynt}";
};
quiet =
Expand Down Expand Up @@ -571,9 +571,9 @@ in
mkOption {
type = types.path;
description = lib.mdDoc "mkdocs-linkcheck binary path. Should be used to specify the mkdocs-linkcheck binary from your Nix-managed Python environment.";
default = "${tools.python311Packages.mkdocs-linkcheck}/bin/mkdocs-linkcheck";
default = "${tools.mkdocs-linkcheck}/bin/mkdocs-linkcheck";
defaultText = lib.literalExpression ''
"''${tools.python311Packages.mkdocs-linkcheck}/bin/mkdocs-linkcheck"
"''${tools.mkdocs-linkcheck}/bin/mkdocs-linkcheck"
'';
};

Expand Down Expand Up @@ -654,9 +654,9 @@ in
mkOption {
type = types.str;
description = lib.mdDoc "PHP-CS-Fixer binary path.";
default = "${tools.php82Packages.php-cs-fixer}/bin/php-cs-fixer";
default = "${tools.php-cs-fixer}/bin/php-cs-fixer";
defaultText = lib.literalExpression ''
"''${tools.php81Packages.php-cs-fixer}/bin/php-cs-fixer"
"''${tools.php-cs-fixer}/bin/php-cs-fixer"
'';
};
};
Expand All @@ -666,9 +666,9 @@ in
mkOption {
type = types.str;
description = lib.mdDoc "PHP_CodeSniffer binary path.";
default = "${tools.php82Packages.phpcbf}/bin/phpcbf";
default = "${tools.phpcbf}/bin/phpcbf";
defaultText = lib.literalExpression ''
"''${tools.php80Packages.phpcbf}/bin/phpcbf"
"''${tools.phpcbf}/bin/phpcbf"
'';
};
};
Expand All @@ -678,9 +678,9 @@ in
mkOption {
type = types.str;
description = lib.mdDoc "PHP_CodeSniffer binary path.";
default = "${tools.php82Packages.phpcs}/bin/phpcs";
default = "${tools.phpcs}/bin/phpcs";
defaultText = lib.literalExpression ''
"''${tools.php80Packages.phpcs}/bin/phpcs"
"''${tools.phpcs}/bin/phpcs"
'';
};
};
Expand All @@ -690,9 +690,9 @@ in
mkOption {
type = types.str;
description = lib.mdDoc "PHPStan binary path.";
default = "${tools.php82Packages.phpstan}/bin/phpstan";
default = "${tools.phpstan}/bin/phpstan";
defaultText = lib.literalExpression ''
"''${tools.php81Packages.phpstan}/bin/phpstan"
"''${tools.phpstan}/bin/phpstan"
'';
};
};
Expand Down Expand Up @@ -942,9 +942,9 @@ in
mkOption {
type = types.str;
description = lib.mdDoc "Psalm binary path.";
default = "${tools.php82Packages.psalm}/bin/psalm";
default = "${tools.psalm}/bin/psalm";
defaultText = lib.literalExpression ''
"''${tools.php81Packages.phpstan}/bin/psalm"
"''${tools.psalm}/bin/psalm"
'';
};
};
Expand All @@ -954,9 +954,9 @@ in
mkOption {
type = types.str;
description = lib.mdDoc "Pylint binary path. Should be used to specify Pylint binary from your Nix-managed Python environment.";
default = "${tools.python39Packages.pylint}/bin/pylint";
default = "${tools.pylint}/bin/pylint";
defaultText = lib.literalExpression ''
"''${tools.python39Packages.pylint}/bin/pylint"
"''${tools.pylint}/bin/pylint"
'';
};
reports =
Expand Down Expand Up @@ -1013,8 +1013,8 @@ in
mkOption {
type = types.path;
description = lib.mdDoc "`rome` binary path. E.g. if you want to use the `rome` in `node_modules`, use `./node_modules/.bin/rome`.";
default = "${tools.rome}/bin/rome";
defaultText = "\${tools.rome}/bin/rome";
default = "${tools.biome}/bin/biome";
defaultText = "\${tools.biome}/bin/biome";
};

write =
Expand Down Expand Up @@ -1281,7 +1281,7 @@ in
{
name = "black";
description = "The uncompromising Python code formatter.";
entry = "${tools.python3Packages.black}/bin/black";
entry = "${tools.black}/bin/black";
types = [ "file" "python" ];
};
cabal-fmt =
Expand Down Expand Up @@ -1836,7 +1836,7 @@ in
[ (profile != "") " --profile ${profile}" ]
]);
in
"${pkgs.python3Packages.isort}/bin/isort${cmdArgs} ${settings.isort.flags}";
"${tools.isort}/bin/isort${cmdArgs} ${settings.isort.flags}";
};
juliaformatter =
{
Expand Down
21 changes: 21 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,27 @@ let
nixpkgs-fmt.enable = true;
};
};
all-tools-eval =
let
config = pkgs.lib.evalModules {
modules = [
../modules/all-modules.nix
{
inherit tools;
settings.treefmt.package = pkgs.treefmt;
}
];
specialArgs = { inherit pkgs; };
};
allHooks = config.config.hooks;
allEntryPoints = pkgs.lib.mapAttrsToList (_: v: v.entry) allHooks;
in
pkgs.runCommand "all-tools-eval"
{
inherit allEntryPoints;
} ''
touch $out
'';
doc-check =
let
inherit (pkgs) lib;
Expand Down
2 changes: 1 addition & 1 deletion nix/headache/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ stdenv.mkDerivation {
name = "headache-stripped";
src = the-headache.src;
phases = [ "installPhase" ];
installPhase = "install -Dm 555 -t $out/bin ${lib.getExe the-headache}";
installPhase = "install -Dm 555 -t $out/bin ${the-headache}/bin/headache";
}
4 changes: 2 additions & 2 deletions nix/terraform-fmt/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ writeScriptBin, terraform }:
{ writeScriptBin, opentofu }:

writeScriptBin "terraform-fmt" ''#!/usr/bin/env bash
for arg in "$@"; do
Expand All @@ -7,6 +7,6 @@ writeScriptBin "terraform-fmt" ''#!/usr/bin/env bash
| sort \
| uniq \
| while read dir; do
${terraform}/bin/terraform fmt "$dir"
${opentofu}/bin/tofu fmt "$dir"
done
''
23 changes: 21 additions & 2 deletions nix/tools.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
, actionlint
, alejandra
, ansible-lint
, biome
, cabal-fmt
, cabal2nix
, callPackage
, cargo
, checkmake
, clang-tools
, clippy
, cljfmt
, cmake-format
, commitizen
, conform
, convco
Expand All @@ -20,6 +23,7 @@
, dune_3
, eclint
, editorconfig-checker
, elixir
, elmPackages
, fprettify
, git
Expand Down Expand Up @@ -48,7 +52,8 @@
, ormolu
, pkgsBuildBuild
, pre-commit-hook-ensure-sops ? null
, python39Packages
, python3Packages
, php82Packages
, ruff ? null
, runCommand
, rustfmt
Expand All @@ -60,11 +65,13 @@
, stylish-haskell
, stylua
, tagref
, taplo
, texlive
, tflint
, topiary ? null ## Added in nixpkgs on Dec 2, 2022
, typos
, typst-fmt
, zprint
, yamllint
, writeScript
, writeText
Expand All @@ -86,11 +93,14 @@ in
alejandra
ansible-lint
beautysh
biome
cabal2nix
cabal-fmt
cargo
clang-tools
clippy
cljfmt
cmake-format
conform
convco
crystal
Expand All @@ -99,6 +109,7 @@ in
dhall
eclint
editorconfig-checker
elixir
fprettify
git-annex
go
Expand Down Expand Up @@ -128,17 +139,25 @@ in
stylish-haskell
stylua
tagref
taplo
topiary
typos
typst-fmt
yamllint
zprint
;
inherit (elmPackages) elm-format elm-review elm-test;
# TODO: these two should be statically compiled
inherit (haskellPackages) fourmolu;
inherit (luaPackages) luacheck;
inherit (nodePackages) eslint markdownlint-cli prettier cspell;
inherit (nodePackages) eslint markdownlint-cli prettier pyright cspell;
inherit (ocamlPackages) ocp-indent;
inherit (python3Packages) autoflake black flake8 flynt isort mkdocs-linkcheck mypy pylint pyupgrade;
inherit (php82Packages) php-cs-fixer phpcbf phpcs psalm;
# FIXME: workaround build failure
phpstan = php82Packages.phpstan.overrideAttrs (old: {
composerStrictValidation = false;
});
lua-language-server = lua-language-server;
purs-tidy = nodePackages.purs-tidy or null;
cabal2nix-dir = callPackage ./cabal2nix-dir { };
Expand Down

0 comments on commit ffa9a5b

Please sign in to comment.