nixpkgs/pkgs/by-name/dp/dprint/package.nix
Kenichi Kamiya c329f0625c
dprint: enable doCheck with some skips
For a preparation task, replace fetchCrate with fetchFromGitHub

- https://github.com/dprint/dprint/blob/0.47.6/Cargo.lock
- https://github.com/dprint/dprint/tree/0.47.6/crates/test-plugin

And skips some tests which cannot be succeeded even if setting DPRINT_CACHE_DIR
2024-12-08 09:43:05 +09:00

78 lines
2.1 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
lib,
stdenv,
fetchFromGitHub,
rustPlatform,
installShellFiles,
testers,
nix-update-script,
dprint,
}:
rustPlatform.buildRustPackage rec {
pname = "dprint";
version = "0.47.6";
# Prefer repository rather than crate here
# - They have Cargo.lock in the repository
# - They have WASM files in the repository which will be used in checkPhase
src = fetchFromGitHub {
owner = "dprint";
repo = "dprint";
rev = "refs/tags/${version}";
hash = "sha256-zyiBFZbetKx0H47MAU4JGauAmthcuEdJMl93M6MobD8=";
};
cargoHash = "sha256-XuzxoJgJJl4Blw1lDnCG3faEqL9U40MhZEb9LYjiaSs=";
nativeBuildInputs = lib.optionals (stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
installShellFiles
];
checkFlags = [
# Require creating directory and network access
"--skip=plugins::cache_fs_locks::test"
"--skip=utils::lax_single_process_fs_flag::test"
# Require cargo is running
"--skip=utils::process::test"
];
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
export DPRINT_CACHE_DIR="$(mktemp -d)"
installShellCompletion --cmd dprint \
--bash <($out/bin/dprint completions bash) \
--zsh <($out/bin/dprint completions zsh) \
--fish <($out/bin/dprint completions fish)
'';
passthru = {
tests.version = testers.testVersion {
inherit version;
package = dprint;
command = ''
DPRINT_CACHE_DIR="$(mktemp --directory)" dprint --version
'';
};
updateScript = nix-update-script { };
};
meta = with lib; {
description = "Code formatting platform written in Rust";
longDescription = ''
dprint is a pluggable and configurable code formatting platform written in Rust.
It offers multiple WASM plugins to support various languages. It's written in
Rust, so its small, fast, and portable.
'';
changelog = "https://github.com/dprint/dprint/releases/tag/${version}";
homepage = "https://dprint.dev";
license = licenses.mit;
maintainers = with maintainers; [
khushraj
kachick
];
mainProgram = "dprint";
};
}