nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildGoModule,
5 fetchFromGitHub,
6 versionCheckHook,
7 nix-update-script,
8}:
9
10buildGoModule rec {
11 pname = "trdsql";
12 version = "1.1.0";
13
14 src = fetchFromGitHub {
15 owner = "noborus";
16 repo = "trdsql";
17 tag = "v${version}";
18 hash = "sha256-MkjQAOIXnydEmOFnnYrvE2TF2I0GqSrSRUAjd+/hHwc=";
19 };
20
21 vendorHash = "sha256-PoIa58vdDPYGL9mjEeudRYqPfvvr3W+fX5c+NgRIoLg=";
22
23 ldflags = [
24 "-s"
25 "-w"
26 "-X github.com/noborus/trdsql.Version=${version}"
27 ];
28
29 # macOS panic: open /etc/protocols: operation not permitted
30 # vendor/modernc.org/libc/libc_darwin.go import vendor/modernc.org/libc/honnef.co/go/netdb
31 # https://gitlab.com/cznic/libc/-/blob/v1.61.6/honnef.co/go/netdb/netdb.go#L697
32 # https://gitlab.com/cznic/libc/-/blob/v1.61.6/honnef.co/go/netdb/netdb.go#L733
33 # this two line read /etc/protocols and /etc/services, which is blocked by darwin sandbox
34 doCheck = !stdenv.hostPlatform.isDarwin;
35
36 doInstallCheck = true;
37 nativeInstallCheckInputs = [ versionCheckHook ];
38 versionCheckProgramArg = "-version";
39 installCheckPhase = ''
40 runHook preInstallCheck
41
42 expected="1,(NULL),v"
43 result=$(echo "1,,v" | $out/bin/trdsql -inull "" -onull "(NULL)" "SELECT * FROM -")
44 if [[ "$result" != "$expected" ]]; then
45 echo "Test gave '$result'. Expected: '$expected'"
46 exit 1
47 fi
48
49 runHook postInstallCheck
50 '';
51
52 passthru.updateScript = nix-update-script { };
53
54 meta = {
55 description = "CLI tool for execute SQL queries on CSV, LTSV, JSON, YAML and TBLN with various output formats";
56 homepage = "https://github.com/noborus/trdsql";
57 changelog = "https://github.com/noborus/trdsql/releases/tag/v${version}";
58 license = lib.licenses.mit;
59 maintainers = with lib.maintainers; [ xiaoxiangmoe ];
60 mainProgram = "trdsql";
61 };
62}