diff options
| author | seth <[email protected]> | 2024-07-05 20:13:36 -0400 |
|---|---|---|
| committer | seth <[email protected]> | 2024-08-23 08:30:49 -0400 |
| commit | 31e5e715321a172cdbd1ba74220d51fae41a3df2 (patch) | |
| tree | e477da3b09e5faafb2fa99c135b0cb24e584f6be | |
| parent | 67fba5edad38f8a4651a6a782c7abdc696a464ff (diff) | |
nix: add dprintPlugins
| -rw-r--r-- | dprintPlugins/default.nix | 25 | ||||
| -rw-r--r-- | dprintPlugins/plugins.nix | 34 | ||||
| -rw-r--r-- | treefmt.nix | 36 |
3 files changed, 94 insertions, 1 deletions
diff --git a/dprintPlugins/default.nix b/dprintPlugins/default.nix new file mode 100644 index 0000000..0462210 --- /dev/null +++ b/dprintPlugins/default.nix @@ -0,0 +1,25 @@ +{ lib, newScope }: +lib.makeScope newScope ( + final: + let + plugins = import ./plugins.nix { + inherit lib; + inherit (final) callPackage; + }; + in + { + mkPlugin = final.callPackage ( + { fetchurl }: + { + pname, + version, + hash, + }: + fetchurl { + url = "https://plugins.dprint.dev/${pname}-${version}.wasm"; + inherit hash; + } + ) { }; + } + // plugins +) diff --git a/dprintPlugins/plugins.nix b/dprintPlugins/plugins.nix new file mode 100644 index 0000000..4a86bb6 --- /dev/null +++ b/dprintPlugins/plugins.nix @@ -0,0 +1,34 @@ +{ lib, callPackage }: +lib.mapAttrs + (pname: { version, hash }: callPackage ({ mkPlugin }: mkPlugin { inherit pname version hash; }) { }) + { + # https://github.com/dprint/dprint-plugin-json + json = { + version = "0.19.3"; + hash = "sha256-6JtfO11zcS8bHKAXvOnN9n3jCn0NukeAeAng0mKwH7k="; + }; + + # https://github.com/dprint/dprint-plugin-markdown + markdown = { + version = "0.17.1"; + hash = "sha256-syZN4k0qelu5giuQtOcgVaZCiVLHXX8lQB9MKgFbvvM="; + }; + + # https://github.com/dprint/dprint-plugin-typescript + typescript = { + version = "0.91.2"; + hash = "sha256-Zz9R/nkyFhBbF+2CE6Ok5v+2CX7uBge1KNUJhBsO0Hg="; + }; + + # https://github.com/g-plane/malva + "g-plane/malva" = { + version = "v0.5.1"; + hash = "sha256-3Cwn5WQMD318ZbjhoXqg59AqRNdkd0oG8BGFtFkCPcI="; + }; + + # https://github.com/g-plane/markup_fmt + "g-plane/markup_fmt" = { + version = "v0.10.0"; + hash = "sha256-NBtKMyf+ObZ0YbZJHfiWly6icwW6K+PUwtnWO6bWjNs="; + }; + } diff --git a/treefmt.nix b/treefmt.nix index a2c5477..b0cf63e 100644 --- a/treefmt.nix +++ b/treefmt.nix @@ -1,9 +1,43 @@ +{ pkgs, ... }: +let + dprintPlugins = pkgs.callPackage ./dprintPlugins { }; +in { projectRootFile = ".git/config"; programs = { + dprint = { + enable = true; + + settings = { + useTabs = true; + + plugins = map toString [ + dprintPlugins.json + dprintPlugins.markdown + dprintPlugins.typescript + dprintPlugins."g-plane/malva" + dprintPlugins."g-plane/markup_fmt" + ]; + + includes = [ "**/*.{css,json,md,ts,tsx}" ]; + + json = { + deno = true; + }; + + markdown = { }; + + typescript = { + deno = true; + }; + + malva = { }; + markup = { }; + }; + }; + deadnix.enable = true; - deno.enable = true; nixfmt.enable = true; statix.enable = true; }; |
