nixpkgs/pkgs/tools/misc/mongodb-tools/default.nix

59 lines
1.2 KiB
Nix
Raw Normal View History

{ lib
, buildGoPackage
, fetchFromGitHub
, openssl
2021-01-17 04:51:22 +01:00
, pkg-config
, libpcap
}:
let
tools = [
"bsondump"
"mongoimport"
"mongoexport"
"mongodump"
"mongorestore"
"mongostat"
"mongofiles"
"mongotop"
];
2021-11-15 22:58:44 +01:00
version = "100.5.1";
in buildGoPackage {
pname = "mongo-tools";
inherit version;
goPackagePath = "github.com/mongodb/mongo-tools";
subPackages = tools;
src = fetchFromGitHub {
2021-11-15 22:58:44 +01:00
rev = version;
owner = "mongodb";
repo = "mongo-tools";
2021-11-15 22:58:44 +01:00
sha256 = "sha256-Qxtb7DJOgrCUvoGVgmKh4qKS4duvEWwW9BLkdt5M5ZY=";
};
2021-01-17 04:51:22 +01:00
nativeBuildInputs = [ pkg-config ];
buildInputs = [ openssl libpcap ];
# Mongodb incorrectly names all of their binaries main
# Let's work around this with our own installer
buildPhase = ''
2018-02-21 22:34:43 +01:00
# move vendored codes so nixpkgs go builder could find it
runHook preBuild
2021-01-15 10:19:50 +01:00
${lib.concatMapStrings (t: ''
go build -o "$out/bin/${t}" -tags ssl -ldflags "-s -w" $goPackagePath/${t}/main
'') tools}
runHook postBuild
'';
meta = {
homepage = "https://github.com/mongodb/mongo-tools";
description = "Tools for the MongoDB";
maintainers = with lib.maintainers; [ bryanasdev000 ];
license = lib.licenses.asl20;
};
}