prettier: Migrate from nodePackages

Co-Authored-By: Robert Schütz <nix@dotlambda.de>
Co-Authored-By: Kira Bruneau <kira.bruneau@pm.me>
Co-Authored-By: Pol Dellaiera <pol.dellaiera@protonmail.com>
This commit is contained in:
Victor Engmark 2025-05-31 08:07:20 +02:00
parent 59138c7667
commit 0e0ac8143c
No known key found for this signature in database
10 changed files with 144 additions and 31 deletions

View file

@ -2,8 +2,8 @@
jq,
lib,
moreutils,
prettier,
vscode-utils,
nodePackages,
}:
vscode-utils.buildVscodeMarketplaceExtension {
@ -19,11 +19,11 @@ vscode-utils.buildVscodeMarketplaceExtension {
moreutils
];
buildInputs = [ nodePackages.prettier ];
buildInputs = [ prettier ];
postInstall = ''
cd "$out/$installPrefix"
jq '.contributes.configuration.properties."prettier.prettierPath".default = "${nodePackages.prettier}/lib/node_modules/prettier"' package.json | sponge package.json
jq '.contributes.configuration.properties."prettier.prettierPath".default = "${prettier}/lib/node_modules/prettier"' package.json | sponge package.json
'';
meta = {

View file

@ -0,0 +1,27 @@
{
"@esbuild/aix-ppc64@npm:0.25.0": "f9a1263789c799c54255f102aa7e5eb92ff2938e5f1e28d7270ae9388d7f0b07a89c6928201089e9917da3531c3370675cbdf3ee213dbb46c219168826dcbf07",
"@esbuild/android-arm64@npm:0.25.0": "b935e4909cfecaf6166268edb337ac481eb79760230efe9893d09dfffc242915307edc890220ff1fe6378f9a6dc88043971a8282929e21ee92d5bb32d1ff33ad",
"@esbuild/android-arm@npm:0.25.0": "109a800ac79c78770cbc5f76c6ba8d2c3a3324c408748016429b5c8aad211463e33d8c0ed7a740f55d8df7a1bac4e78bc5029521f07e740731b7564c688c2206",
"@esbuild/android-x64@npm:0.25.0": "033e21f87df0b0a50b6f54de5ba2dc20c232f008fc62c377c8a359dc27c6d96eaaf57fab8c87c829e36fb49249811bcb0dfb0df958fc2cd1a2311fe443db7a2c",
"@esbuild/darwin-arm64@npm:0.25.0": "d82d5f8b724a77ee7d65b7d47159930015135c7fb0fc7dc3ad056203bb97a1a933f516fd91f0213420a80c0a9ddfec954c952c554edf00629d9bc964313a3836",
"@esbuild/darwin-x64@npm:0.25.0": "ae029503666bfa48c6cbcbc991ac9d841e1f03f056f71782b78e57ac4083022eb505deab330651ee05deab76688cf3139bdbea84caea6491fcaf5caa2b912946",
"@esbuild/freebsd-arm64@npm:0.25.0": "9f72aaa0c1845f3ada5a6a1cffa43c7683c25313455aa997ca8b233316a87d163722d8c26a0e86663c5ebbdca6ab91cf1975f0c0e7fbe062087cbef92c666b04",
"@esbuild/freebsd-x64@npm:0.25.0": "b96749a6d7da71fff98309655eb85b09de84416ae5c09a02e803342bba25c81e0ac181212bac49fa8d8cc28bfa5e1fbb8d349f2b4722e2ca2df2e4a383d17935",
"@esbuild/linux-arm64@npm:0.25.0": "1dbf78595fed87287eccde8fb9a5e35d448ab3b7cd84c03fdfa47c250701a62160d7aa45b4de9ca5e11039975680829644529636bbe254e1627836c5227efca2",
"@esbuild/linux-arm@npm:0.25.0": "b1a165678166d006b32f965cb51719403fdea18c9ec2e498807f0b273b46a3a555b214d5d5f832393471180e1d39ca9f06e7bfe3c2c97c0cbc30314a38b422c0",
"@esbuild/linux-ia32@npm:0.25.0": "21a136d8301fac7f23724061832426efddc2f9769b29b37e88443245ed0406f0b1f9bc05a02b6d0cf7b3e2e8ec2c8e1e8d99b3178a01ace6974369930f0020f6",
"@esbuild/linux-loong64@npm:0.25.0": "f87baa1534a52b24198d9d845821f37bec9c4afb08307ee66c3f1d223d3c684151749f4a0eeb96f3905d365bea9f6256787256ff35b9f80fdd51ed7d4f8356b6",
"@esbuild/linux-mips64el@npm:0.25.0": "2bfdec2d2730879795f6884d8f8a38a0297f0cd46bc3357c568fc59432d49d7e26c723d9b8111c799517628cafb469e30fa968387105079aa4b4b4d4192638bf",
"@esbuild/linux-ppc64@npm:0.25.0": "bca7b660b91939b5d9f4942b4f2e404efad88fa166c51ba49474b3b5ba200213e1c44499c419d2b13c5afe01b560f361b46d201acc146d76515b953be497bd4f",
"@esbuild/linux-riscv64@npm:0.25.0": "dfb00cd66f717315b9afab667a484c67a69a7a3f6bb9e4662cd3dd0b7465da3feb5182bca414ce0ad0f7a95d0a1fd248c792561c63008d483146eff8af6e678c",
"@esbuild/linux-s390x@npm:0.25.0": "4c5872f244ade04c71f1d0f14bd0d3ef0cd24c5404e55e33964fa5ce7b6f2e1283e9d9adb5356db76468cd85724f6cfdb1cd9674ad630344a7d01ca614bf59e3",
"@esbuild/linux-x64@npm:0.25.0": "22f6bfbb856653ee8cff0a93ce63947fd3bd4565c8bc7e9d437845fc4b44a2b3954b5e412b4aa4b63e62977beca12e0214b2607c7bc8c4ce359bd10118755df4",
"@esbuild/netbsd-arm64@npm:0.25.0": "a8286e8b687857779047d005d4a540a693a2e173893a34273773d0272e9908006e10085a52788f54775ca231ad231e8a7af9270dbd8203b9182dbe2c7fee68b6",
"@esbuild/netbsd-x64@npm:0.25.0": "e618540e5e086cabc260010e62110a8afb5b0dfc445e5cd6db843d8a7541403decee971265c5cf59e6f1268b03e8fb50e27b65f709faf647c4e20e0916f19621",
"@esbuild/openbsd-arm64@npm:0.25.0": "60cc4ce058e03389155dd34f777d4d5cae1fb62f9bb9659c615ce5d70e8093a58aa89a9ebb8fde4d2dba56e5771c6aaf4442db45f4a1c9d54d6c36a149b857d0",
"@esbuild/openbsd-x64@npm:0.25.0": "7ba16accc220c711d1bcbb17ada40de4503f9ed54b8a42957345a8a9b9a7c55eac550b234c6a5a812acf50386f2972fb6a5b0381b38f76cff4b3c44ba38ae1ac",
"@esbuild/sunos-x64@npm:0.25.0": "e6cbfb0a93b9f78ef991ff43af2ab33faacf382d9b8db44bf53a80b3fc27a9d0f598061b9a77de1db9481d69fd43a3fd4b20a40a2938923fa52cabdcac84e972",
"@esbuild/win32-arm64@npm:0.25.0": "47bd8e32c90da8472515ddc625e6284cf745b1b9eeecf16e2e699b94b3d11c2d773b16944c8de33d857a8e59426601063a3df04433cb670ed3e8421def07d96b",
"@esbuild/win32-ia32@npm:0.25.0": "072874686fe049446bba0ec18285414275ac74e8232307a856966ede8a822e72ab9f6119f7352f8feb51c629a20065dbc88f4412120480fe5bcc039dd439d0a7",
"@esbuild/win32-x64@npm:0.25.0": "ce021c1bb895345ee30f363d89e1f3631040fb44d2e27e614b65dc697090c30c5b66b80aa9d6e5e3b3153010b37e523d6ef34c7b4f2248192b1b4bdd30701b3f"
}

View file

@ -0,0 +1,64 @@
{
fetchFromGitHub,
lib,
makeBinaryWrapper,
nodejs,
stdenv,
versionCheckHook,
yarn-berry,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "prettier";
version = "3.5.3";
src = fetchFromGitHub {
owner = "prettier";
repo = "prettier";
tag = finalAttrs.version;
hash = "sha256-jde5kU6wNJeNKtW2WlKaK9DkKOluiUy7KaonZVdwUxE=";
};
missingHashes = ./missing-hashes.json;
offlineCache = yarn-berry.fetchYarnBerryDeps {
inherit (finalAttrs) src missingHashes;
hash = "sha256-Yd1rHcPxKjGe8P1OuGrFjKgBnGTD+bSJP1iA0yHM6uM=";
};
nativeBuildInputs = [
makeBinaryWrapper
yarn-berry
yarn-berry.yarnBerryConfigHook
];
installPhase = ''
runHook preInstall
yarn install --immutable
yarn build --clean
mkdir "$out"
cp --recursive dist/* "$out"
makeBinaryWrapper "${lib.getExe nodejs}" "$out/bin/prettier" \
--add-flags "$out/bin/prettier.cjs"
runHook postInstall
'';
nativeInstallCheckInputs = [
versionCheckHook
];
doInstallCheck = true;
passthru.updateScript = ./update.sh;
meta = {
changelog = "https://github.com/prettier/prettier/blob/${finalAttrs.version}/CHANGELOG.md";
description = "Code formatter";
homepage = "https://prettier.io/";
license = lib.licenses.mit;
mainProgram = "prettier";
maintainers = with lib.maintainers; [ l0b0 ];
};
})

View file

@ -0,0 +1,47 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl common-updater-scripts coreutils jq yarn-berry.yarn-berry-fetcher
set -o errexit -o nounset -o pipefail
set -o xtrace # debugging
# Configuration
owner='prettier'
repo='prettier'
package='prettier'
cleanup() {
rm --force --recursive "${tmpdir}"
}
trap cleanup EXIT
tmpdir="$(mktemp --directory)"
disable_cleanup() {
# We want to keep the temporary directory in case of error
trap - EXIT
}
trap disable_cleanup ERR
curl_command=(curl --fail ${GITHUB_TOKEN:+--user ":${GITHUB_TOKEN}"})
jq_command=(jq --raw-output)
current_version=$(nix-instantiate --eval --expr "with import ./. {}; ${package}.version or (lib.getVersion ${package})" --raw)
echo "Current version: ${current_version}"
latest_version="$("${curl_command[@]}" "https://api.github.com/repos/${owner}/${repo}/releases/latest" | "${jq_command[@]}" .tag_name)"
echo "Latest version: ${latest_version}"
if [[ "${current_version}" == "${latest_version}" ]]; then
echo "${package} is up to date: ${current_version}"
exit 0
else
echo "Updating ${package} from ${current_version} to ${latest_version}"
fi
package_dir="pkgs/by-name/${package::2}/${package}"
"${curl_command[@]}" --output "${package_dir}/package.json" "https://raw.githubusercontent.com/${owner}/${repo}/${latest_version}/package.json"
update-source-version "${package}" "${latest_version}"
echo "Update yarn offline cache hash…"
nix-build --attr "${package}.src"
yarn-berry-fetcher missing-hashes result/yarn.lock >"${package_dir}/missing-hashes.json"

View file

@ -174,6 +174,7 @@ mapAliases {
inherit (pkgs) pm2; # added 2024-01-22
inherit (pkgs) pnpm; # added 2024-06-26
postcss-cli = throw "postcss-cli has been removed because it was broken"; # added 2025-03-24
inherit (pkgs) prettier; # added 2025-05-31
prettier_d_slim = pkgs.prettier-d-slim; # added 2023-09-14
prettier-plugin-toml = throw "prettier-plugin-toml was removed because it provides no executable"; # added 2025-03-23
inherit (pkgs) prisma; # added 2024-08-31

View file

@ -34,7 +34,6 @@
lua-fmt = "luafmt";
parsoid = "parse.js";
poor-mans-t-sql-formatter-cli = "sqlformat";
prettier = "prettier";
pulp = "pulp";
purescript-language-server = "purescript-language-server";
purescript-psa = "psa";

View file

@ -130,7 +130,6 @@
, "poor-mans-t-sql-formatter-cli"
, "postcss"
, "prebuild-install"
, "prettier"
, "pscid"
, "pulp"
, "purescript-language-server"

View file

@ -61456,24 +61456,6 @@ in
bypassCache = true;
reconstructLock = true;
};
prettier = nodeEnv.buildNodePackage {
name = "prettier";
packageName = "prettier";
version = "3.5.3";
src = fetchurl {
url = "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz";
sha512 = "QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==";
};
buildInputs = globalBuildInputs;
meta = {
description = "Prettier is an opinionated code formatter";
homepage = "https://prettier.io";
license = "MIT";
};
production = true;
bypassCache = true;
reconstructLock = true;
};
pscid = nodeEnv.buildNodePackage {
name = "pscid";
packageName = "pscid";

View file

@ -231,12 +231,6 @@ final: prev: {
};
};
prettier = prev.prettier.override {
passthru.tests.version = pkgs.testers.testVersion {
package = final.prettier;
};
};
wavedrom-cli = prev.wavedrom-cli.override {
nativeBuildInputs = [
pkgs.pkg-config

View file

@ -2,8 +2,8 @@
lib,
buildBatExtrasPkg,
shfmt,
nodePackages,
clang-tools,
prettier,
rustfmt,
withShFmt ? true,
@ -15,7 +15,7 @@ buildBatExtrasPkg {
name = "prettybat";
dependencies =
lib.optional withShFmt shfmt
++ lib.optional withPrettier nodePackages.prettier
++ lib.optional withPrettier prettier
++ lib.optional withClangTools clang-tools
++ lib.optional withRustFmt rustfmt;
meta.description = "Pretty-print source code and highlight it with bat";