nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildGoModule,
4 fetchFromGitHub,
5 openssl,
6 pkg-config,
7 libpcap,
8 nix-update-script,
9}:
10
11buildGoModule rec {
12 pname = "mongo-tools";
13 version = "100.14.1";
14
15 src = fetchFromGitHub {
16 owner = "mongodb";
17 repo = "mongo-tools";
18 tag = version;
19 hash = "sha256-+3Cmaa0913TKj/nMmTxXQeegPEZ1NUdusTbKZ86LqLY=";
20 };
21
22 vendorHash = null;
23
24 nativeBuildInputs = [ pkg-config ];
25 buildInputs = [
26 openssl
27 libpcap
28 ];
29
30 # Mongodb incorrectly names all of their binaries main
31 # Let's work around this with our own installer
32 buildPhase =
33 let
34 tools = [
35 "bsondump"
36 "mongodump"
37 "mongoexport"
38 "mongofiles"
39 "mongoimport"
40 "mongorestore"
41 "mongostat"
42 "mongotop"
43 ];
44 in
45 ''
46 # move vendored codes so nixpkgs go builder could find it
47 runHook preBuild
48
49 ${lib.concatMapStrings (t: ''
50 go build -o "$out/bin/${t}" -tags ssl -ldflags "-s -w" ./${t}/main
51 '') tools}
52
53 runHook postBuild
54 '';
55
56 passthru.updateScript = nix-update-script { };
57
58 meta = {
59 homepage = "https://github.com/mongodb/mongo-tools";
60 description = "Tools for the MongoDB";
61 license = lib.licenses.asl20;
62 maintainers = with lib.maintainers; [
63 iamanaws
64 ];
65 };
66}