Skip to content

Commit

Permalink
dprint-plugins: init
Browse files Browse the repository at this point in the history
Signed-off-by: phanirithvij <[email protected]>
  • Loading branch information
phanirithvij committed Dec 30, 2024
1 parent f7c8b09 commit bf1665b
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkgs/by-name/dp/dprint/plugins/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
lib,
fetchurl,
}:
let
inherit (lib) mapAttrs;
plugins = builtins.fromJSON (builtins.readFile ./plugins.json);
in
mapAttrs (_: fetchurl) plugins
50 changes: 50 additions & 0 deletions pkgs/by-name/dp/dprint/plugins/plugins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"typescript": {
"url": "https://plugins.dprint.dev/typescript-0.93.3.wasm",
"hash": "sha256-urgKQOjgkoDJCH/K7DWLJCkD0iH0Ok+rvrNDI0i4uS0="
},
"json": {
"url": "https://plugins.dprint.dev/json-0.19.4.wasm",
"hash": "sha256-Sw+HkUb4K2wrLuQRZibr8gOCR3Rz36IeId4Vd4LijmY="
},
"markdown": {
"url": "https://plugins.dprint.dev/markdown-0.17.8.wasm",
"hash": "sha256-PIEN9UnYC8doJpdzS7M6QEHQNQtj7WwXAgvewPsTjqs="
},
"toml": {
"url": "https://plugins.dprint.dev/toml-0.6.3.wasm",
"hash": "sha256-aDfo/sKfOeNpyfd/4N1LgL1bObTTnviYrA8T7M/1KNs="
},
"dockerfile": {
"url": "https://plugins.dprint.dev/dockerfile-0.3.2.wasm",
"hash": "sha256-gsfMLa4zw8AblOS459ZS9OZrkGCQi5gBN+a3hvOsspk="
},
"biome": {
"url": "https://plugins.dprint.dev/biome-0.7.1.wasm",
"hash": "sha256-+zY+myazFAUxeNuWFigkvF4zpKBs+jzVYQT09jRWFKI="
},
"ruff": {
"url": "https://plugins.dprint.dev/ruff-0.3.9.wasm",
"hash": "sha256-15InHQgF9c0Js4yUJxmZ1oNj1O16FBU12u/GOoaSAJ8="
},
"jupyter": {
"url": "https://plugins.dprint.dev/jupyter-0.1.5.wasm",
"hash": "sha256-877CEZbMlj9cHkFtl16XCnan37SeEGUL3BHaUKUv8S4="
},
"malva": {
"url": "https://plugins.dprint.dev/g-plane/malva-v0.11.1.wasm",
"hash": "sha256-zt7F1tgPhPAn+gtps6+JB5RtvjIZw2n/G85Bv6kazgU="
},
"markup": {
"url": "https://plugins.dprint.dev/g-plane/markup_fmt-v0.18.0.wasm",
"hash": "sha256-G8UnJbc+oZ60V3oi8W2SS6H06zEYfY3wpmSUp+1GF8k="
},
"yaml": {
"url": "https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.0.wasm",
"hash": "sha256-6ua021G7ZW7Ciwy/OHXTA1Joj9PGEx3SZGtvaA//gzo="
},
"graphql": {
"url": "https://plugins.dprint.dev/g-plane/pretty_graphql-v0.2.1.wasm",
"hash": "sha256-PlQwpR0tMsghMrOX7is+anN57t9xa9weNtoWpc0E9ec="
}
}
41 changes: 41 additions & 0 deletions pkgs/by-name/dp/dprint/plugins/update-plugins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env nix-shell
#!nix-shell -i python -p nix 'python3.withPackages (pp: with pp; [ requests ])'

import json
import subprocess
import requests


def nix_prefetch_url(url, algo="sha256"):
hash = (
subprocess.check_output(["nix-prefetch-url", "--type", algo, url])
.decode("utf-8")
.rstrip()
)
sri = (
subprocess.check_output(
["nix", "hash", "convert", "--hash-algo", algo, "--to", "sri", hash]
)
.decode("utf-8")
.rstrip()
)
return sri


def update_plugins():
data = requests.get("https://plugins.dprint.dev/info.json").json()["latest"]
with open("plugins.json", "w+", encoding="utf8") as f:
result = {}
for e in data:
# using configKey instead of name here
# name can have slashes for eg. g-plane/malva
# but configKey is a good sensible unique word per plugin
result[e["configKey"]] = {
"url": e["url"],
"hash": nix_prefetch_url(e["url"]),
}
json.dump(result, f, indent=2)
f.write("\n")


update_plugins()
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5919,6 +5919,8 @@ with pkgs;

devpi-server = python3Packages.callPackage ../development/tools/devpi-server { };

dprint-plugins = recurseIntoAttrs (callPackage ../by-name/dp/dprint/plugins { });

elm2nix = haskell.lib.compose.justStaticExecutables haskellPackages.elm2nix;

elmPackages = recurseIntoAttrs (callPackage ../development/compilers/elm { });
Expand Down

0 comments on commit bf1665b

Please sign in to comment.