nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 rustPlatform,
4 fetchFromGitHub,
5 stdenv,
6 nix-update-script,
7 versionCheckHook,
8}:
9rustPlatform.buildRustPackage rec {
10 pname = "sqruff";
11 version = "0.34.1";
12
13 src = fetchFromGitHub {
14 owner = "quarylabs";
15 repo = "sqruff";
16 tag = "v${version}";
17 hash = "sha256-Yk4ejrIs8/8RVvXS2V2ZTBn6zawVO502Xeeb8rjU6e4=";
18 };
19
20 cargoHash = "sha256-4jB1chciQaR/RYhRTfwWOOUIZgePezl8lAngpfoSuJc=";
21
22 # Disable the `python` feature which doesn't work on Nix yet
23 buildNoDefaultFeatures = true;
24 buildAndTestSubdir = "crates/cli";
25
26 # Patch the tests to find the sqruff binary
27 postPatch = ''
28 substituteInPlace \
29 crates/cli/tests/config_not_found.rs \
30 crates/cli/tests/configure_rule.rs \
31 crates/cli/tests/dialect_override.rs \
32 crates/cli/tests/fix_parse_errors.rs \
33 crates/cli/tests/fix_return_code.rs \
34 crates/cli/tests/ignore_data_directory.rs \
35 crates/cli/tests/verbose_logging_ignore.rs \
36 crates/cli/tests/ui_github.rs \
37 crates/cli/tests/ui_json.rs \
38 crates/cli/tests/ui.rs \
39 --replace-fail \
40 '"../../target/{}/sqruff"' \
41 '"../../target/${stdenv.hostPlatform.rust.cargoShortTarget}/{}/sqruff"'
42 '';
43
44 nativeCheckInputs = [ versionCheckHook ];
45 doInstallCheck = true;
46
47 passthru = {
48 updateScript = nix-update-script { };
49 };
50
51 meta = {
52 description = "Fast SQL formatter/linter";
53 homepage = "https://github.com/quarylabs/sqruff";
54 changelog = "https://github.com/quarylabs/sqruff/releases/tag/${version}";
55 license = lib.licenses.asl20;
56 mainProgram = "sqruff";
57 maintainers = with lib.maintainers; [
58 hasnep
59 pyrox0
60 ];
61 };
62}