From c329f0625c80af08ed35db3460e0eecc3827080a Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Sat, 7 Dec 2024 00:27:03 +0900 Subject: [PATCH] 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 --- pkgs/by-name/dp/dprint/package.nix | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/pkgs/by-name/dp/dprint/package.nix b/pkgs/by-name/dp/dprint/package.nix index 1b3cb8f91e2e..05543ec1217c 100644 --- a/pkgs/by-name/dp/dprint/package.nix +++ b/pkgs/by-name/dp/dprint/package.nix @@ -1,7 +1,7 @@ { lib, stdenv, - fetchCrate, + fetchFromGitHub, rustPlatform, installShellFiles, testers, @@ -13,21 +13,30 @@ rustPlatform.buildRustPackage rec { pname = "dprint"; version = "0.47.6"; - src = fetchCrate { - inherit pname version; - hash = "sha256-7tGzSFp7Dnu27L65mqFd7hzeFFDfe1xJ6cMul3hGyJs="; + # 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-y3tV3X7YMOUGBn2hCmxsUUc9QQleKEioTIw7SGoBvSQ="; - - # Tests fail because they expect a test WASM plugin. Tests already run for - # every commit upstream on GitHub Actions - doCheck = false; + 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 \