diff --git a/flake-modules/dev/default.nix b/flake-modules/dev/default.nix index f9dd03173..d05d6f4ef 100644 --- a/flake-modules/dev/default.nix +++ b/flake-modules/dev/default.nix @@ -1,88 +1,7 @@ -{ lib, inputs, ... }: { - imports = - [ ./devshell.nix ] - ++ lib.optional (inputs.git-hooks-nix ? flakeModule) inputs.git-hooks-nix.flakeModule - ++ lib.optional (inputs.treefmt-nix ? flakeModule) inputs.treefmt-nix.flakeModule; - - perSystem = - { - lib, - pkgs, - ... - }: - lib.optionalAttrs (inputs.treefmt-nix ? flakeModule) { - treefmt.config = { - projectRootFile = "flake.nix"; - flakeCheck = true; - - programs = { - actionlint.enable = true; - clang-format.enable = true; - isort.enable = true; - nixfmt = { - enable = true; - package = pkgs.nixfmt-rfc-style; - }; - prettier = { - enable = true; - - excludes = [ "**.md" ]; - }; - ruff = { - check = true; - format = true; - }; - statix.enable = true; - stylua.enable = true; - shfmt.enable = true; - taplo.enable = true; - }; - - settings = { - global.excludes = [ - ".editorconfig" - ".envrc" - ".git-blame-ignore-revs" - ".gitignore" - "LICENSE" - "flake.lock" - "**.md" - "**.scm" - "**.svg" - "**/man/*.5" - ]; - formatter.ruff-format.options = [ "--isolated" ]; - }; - }; - } - // lib.optionalAttrs (inputs.git-hooks-nix ? flakeModule) { - pre-commit = { - check.enable = false; - - settings.hooks = { - actionlint.enable = true; - clang-tidy.enable = true; - deadnix = { - enable = true; - - settings = { - edit = true; - }; - }; - eslint = { - enable = true; - package = pkgs.eslint_d; - }; - luacheck.enable = true; - pre-commit-hook-ensure-sops.enable = true; - statix.enable = true; - treefmt.enable = true; - typos = { - enable = true; - excludes = [ "generated/*" ]; - }; - }; - }; - }; + imports = [ + ./devshell.nix + ./git-hooks.nix + ./treefmt.nix + ]; } diff --git a/flake-modules/dev/git-hooks.nix b/flake-modules/dev/git-hooks.nix new file mode 100644 index 000000000..47527d691 --- /dev/null +++ b/flake-modules/dev/git-hooks.nix @@ -0,0 +1,40 @@ +{ lib, inputs, ... }: +{ + imports = lib.optional (inputs.git-hooks-nix ? flakeModule) inputs.git-hooks-nix.flakeModule; + + perSystem = + { + lib, + pkgs, + ... + }: + lib.optionalAttrs (inputs.git-hooks-nix ? flakeModule) { + pre-commit = { + check.enable = false; + + settings.hooks = { + actionlint.enable = true; + clang-tidy.enable = true; + deadnix = { + enable = true; + + settings = { + edit = true; + }; + }; + eslint = { + enable = true; + package = pkgs.eslint_d; + }; + luacheck.enable = true; + pre-commit-hook-ensure-sops.enable = true; + statix.enable = true; + treefmt.enable = true; + typos = { + enable = true; + excludes = [ "generated/*" ]; + }; + }; + }; + }; +} diff --git a/flake-modules/dev/treefmt.nix b/flake-modules/dev/treefmt.nix new file mode 100644 index 000000000..c251bb759 --- /dev/null +++ b/flake-modules/dev/treefmt.nix @@ -0,0 +1,56 @@ +{ lib, inputs, ... }: +{ + imports = lib.optional (inputs.treefmt-nix ? flakeModule) inputs.treefmt-nix.flakeModule; + + perSystem = + { + lib, + pkgs, + ... + }: + lib.optionalAttrs (inputs.treefmt-nix ? flakeModule) { + treefmt.config = { + projectRootFile = "flake.nix"; + flakeCheck = true; + + programs = { + actionlint.enable = true; + clang-format.enable = true; + isort.enable = true; + nixfmt = { + enable = true; + package = pkgs.nixfmt-rfc-style; + }; + prettier = { + enable = true; + + excludes = [ "**.md" ]; + }; + ruff = { + check = true; + format = true; + }; + statix.enable = true; + stylua.enable = true; + shfmt.enable = true; + taplo.enable = true; + }; + + settings = { + global.excludes = [ + ".editorconfig" + ".envrc" + ".git-blame-ignore-revs" + ".gitignore" + "LICENSE" + "flake.lock" + "**.md" + "**.scm" + "**.svg" + "**/man/*.5" + ]; + formatter.ruff-format.options = [ "--isolated" ]; + }; + }; + }; +}