58 lines
1.6 KiB
Nix
58 lines
1.6 KiB
Nix
|
|
{
|
||
|
|
lib,
|
||
|
|
rustPlatform,
|
||
|
|
fetchFromGitHub,
|
||
|
|
stdenv,
|
||
|
|
nix-update-script,
|
||
|
|
versionCheckHook,
|
||
|
|
}:
|
||
|
|
rustPlatform.buildRustPackage rec {
|
||
|
|
pname = "sqruff";
|
||
|
|
version = "0.29.3";
|
||
|
|
|
||
|
|
src = fetchFromGitHub {
|
||
|
|
owner = "quarylabs";
|
||
|
|
repo = "sqruff";
|
||
|
|
tag = "v${version}";
|
||
|
|
hash = "sha256-bJmkHOACjdSXHE56okrIFERs1wK00XeyipdIFbRjIFI=";
|
||
|
|
};
|
||
|
|
|
||
|
|
cargoHash = "sha256-TxADMtapo6Pc4Z0MUkzkzUIrLnGa1DdZFzfTq4buF4g=";
|
||
|
|
|
||
|
|
# Disable the `python` feature which doesn't work on Nix yet
|
||
|
|
buildNoDefaultFeatures = true;
|
||
|
|
buildAndTestSubdir = "crates/cli";
|
||
|
|
|
||
|
|
# Patch the tests to find the sqruff binary
|
||
|
|
postPatch = ''
|
||
|
|
substituteInPlace \
|
||
|
|
crates/cli/tests/config_not_found.rs \
|
||
|
|
crates/cli/tests/configure_rule.rs \
|
||
|
|
crates/cli/tests/fix_parse_errors.rs \
|
||
|
|
crates/cli/tests/fix_return_code.rs \
|
||
|
|
crates/cli/tests/ui_github.rs \
|
||
|
|
crates/cli/tests/ui_json.rs \
|
||
|
|
crates/cli/tests/ui.rs \
|
||
|
|
--replace-fail \
|
||
|
|
'sqruff_path.push(format!("../../target/{}/sqruff", profile));' \
|
||
|
|
'sqruff_path.push(format!("../../target/${stdenv.hostPlatform.rust.cargoShortTarget}/{}/sqruff", profile));'
|
||
|
|
'';
|
||
|
|
|
||
|
|
nativeCheckInputs = [ versionCheckHook ];
|
||
|
|
versionCheckProgramArg = "--version";
|
||
|
|
doInstallCheck = true;
|
||
|
|
|
||
|
|
passthru = {
|
||
|
|
updateScript = nix-update-script { };
|
||
|
|
};
|
||
|
|
|
||
|
|
meta = {
|
||
|
|
description = "Fast SQL formatter/linter";
|
||
|
|
homepage = "https://github.com/quarylabs/sqruff";
|
||
|
|
changelog = "https://github.com/quarylabs/sqruff/releases/tag/${version}";
|
||
|
|
license = lib.licenses.asl20;
|
||
|
|
mainProgram = "sqruff";
|
||
|
|
maintainers = with lib.maintainers; [ hasnep ];
|
||
|
|
};
|
||
|
|
}
|