nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 buildGoModule,
3 fetchFromGitHub,
4 installShellFiles,
5 lib,
6 sqlcmd,
7 testers,
8}:
9
10buildGoModule rec {
11 pname = "sqlcmd";
12 version = "1.9.0";
13
14 src = fetchFromGitHub {
15 repo = "go-sqlcmd";
16 owner = "microsoft";
17 rev = "v${version}";
18 sha256 = "sha256-9De00wIuSgg7Z1LCsj3tODImyQJxYFINtqt6PSvrK/Y=";
19 };
20
21 vendorHash = "sha256-3VORKnBt+HUiFMszw19wiGOUra0K72R5M6OPhPZs+yw=";
22 proxyVendor = true;
23
24 ldflags = [
25 "-s"
26 "-w"
27 "-X main.version=${version}"
28 ];
29
30 subPackages = [ "cmd/modern" ];
31
32 nativeBuildInputs = [ installShellFiles ];
33
34 preCheck = ''
35 export HOME=$(mktemp -d)
36 '';
37
38 postInstall = ''
39 mv $out/bin/modern $out/bin/sqlcmd
40
41 installShellCompletion --cmd sqlcmd \
42 --bash <($out/bin/sqlcmd completion bash) \
43 --fish <($out/bin/sqlcmd completion fish) \
44 --zsh <($out/bin/sqlcmd completion zsh)
45 '';
46
47 passthru.tests.version = testers.testVersion {
48 package = sqlcmd;
49 command = "sqlcmd --version";
50 inherit version;
51 };
52
53 meta = {
54 description = "Command line tool for working with Microsoft SQL Server, Azure SQL Database, and Azure Synapse";
55 mainProgram = "sqlcmd";
56 homepage = "https://github.com/microsoft/go-sqlcmd";
57 changelog = "https://github.com/microsoft/go-sqlcmd/releases/tag/v${version}";
58 license = lib.licenses.mit;
59 maintainers = [ lib.maintainers.ratsclub ];
60 };
61}