Skip to content

Commit

Permalink
mongodb 6.0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
undefined-moe committed Nov 28, 2023
1 parent 289262c commit 56c8af1
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 24 deletions.
5 changes: 3 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ let

self = {
mongodb = import ./mongodb.nix;
mongodb6 = callPackage ./mongodb.nix { version = "6.0.0"; inherit system; };
mongodb7 = callPackage ./mongodb.nix { version = "7.0.4"; inherit system; };
mongodb6 = callPackage ./mongodb.nix { version = "6.0.12"; inherit system; };
mongodb5 = callPackage ./mongodb.nix { version = "5.0.10"; inherit system; };
mongodb4 = callPackage ./mongodb.nix { version = "4.4.16"; inherit system; };
mongodb6-cn = callPackage ./mongodb.nix { version = "6.0.0"; mirror = tuna; inherit system; };
mongodb6-cn = callPackage ./mongodb.nix { version = "6.0.12"; mirror = tuna; inherit system; };
mongodb5-cn = callPackage ./mongodb.nix { version = "5.0.10"; mirror = tuna; inherit system; };
mongodb4-cn = callPackage ./mongodb.nix { version = "4.4.16"; mirror = tuna; inherit system; };
sandbox = callPackage ./sandbox.nix { inherit system; };
Expand Down
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
{
packages.judge = (import ./judge.nix)
{ pkgs = nixpkgs.legacyPackages.${system}; system = system; };
packages.mongodb = (import ./mongodb.nix)
{ pkgs = nixpkgs.legacyPackages.${system}; system = system; };
}
);
}
68 changes: 46 additions & 22 deletions mongodb.nix
Original file line number Diff line number Diff line change
@@ -1,46 +1,70 @@
{
system ? builtins.currentSystem,
pkgs ? import <nixpkgs> { system = system; },
version ? "5.0.6",
mirror ? "https://repo.mongodb.org/"
{ system ? builtins.currentSystem
, pkgs ? import <nixpkgs> { system = system; }
, version ? "6.0.12"
, mirror ? "https://repo.mongodb.org/"
}:

let
sversion = pkgs.lib.splitString "." version;
major = pkgs.lib.elemAt sversion 0;
minor = pkgs.lib.elemAt sversion 1;
major = pkgs.lib.elemAt (pkgs.lib.splitString "." version) 0;
sha256dict = {
"4.4.16x86_64-linux" = "sha256-JZjGYCF5Ip0wqr+GTlHw9jdY0ZsswPN0aLdFAK1C35M=";
"5.0.10x86_64-linux" = "sha256-NV+a1bBdY5z2559cJYgNYlTvoRfGHVWrvmyWcCLgxls=";
"6.0.0x86_64-linux" = "sha256-AJUQ8Jo/T4PDnYtFg3njUZyoH9XXzleZ+nj/knCBKzg=";
"6.0.12x86_64-linux" = "sha256-7HHYBSMYudDUg/8HiCRkn4iCAjIkLpZLCeokLTHLgUA=";
"7.0.4x86_64-linux" = "sha256-6C/K+SwEMAX1wsJH1ltQAVWjKY2aNqfqv5EXcER4WCY=";
"4.4.16aarch64-linux" = "sha256-8L+4uwIvhuVw9t4N1CuStHnwIZhOdZqiBsjcN+iIyBI=";
"5.0.10aarch64-linux" = "sha256-phLLCL1wXE0pjrb4n1xQjoTVDYuFFRz5RQdfmYj9HPY=";
"6.0.0aarch64-linux" = "sha256-nEmpS2HUeQdehQAiFgxKLnnYVV9aPKtUtb/GRS9f+4M=";
"6.0.12aarch64-linux" = "sha256-OEZKPsvDARZOBECg083inqfqPc6jnjckY1IY2Yb3IbE=";
};
archDict = {
"x86_64-linux" = "amd64";
"aarch64-linux" = "arm64";
};
arch = pkgs.lib.getAttr system archDict;
versionDetail = pkgs.lib.concatStrings [version system];
in pkgs.stdenvNoCC.mkDerivation {
versionDetail = pkgs.lib.concatStrings [ version system ];
buildDownloadUrl = system: version:
let
archDict = {
"x86_64-linux" = "amd64";
"aarch64-linux" = "arm64";
};
arch = pkgs.lib.getAttr system archDict;
sversion = pkgs.lib.splitString "." version;
major = pkgs.lib.elemAt sversion 0;
minor = pkgs.lib.elemAt sversion 1;
nmajor = pkgs.lib.strings.toInt major;
in
pkgs.lib.concatStrings [
mirror
# Prefer debian bookworm as its package was built with openssl3
(if nmajor >= 7 then "apt/debian/dists/bookworm" else "apt/ubuntu/dists/bionic")
"/mongodb-org/"
"${major}.${minor}"
(if nmajor >= 7 then "/main" else "/multiverse")
"/binary-"
arch
"/mongodb-org-server_"
version
"_"
arch
".deb"
];
in
pkgs.stdenvNoCC.mkDerivation {
name = "hydro-mongodb-${version}";
system = system;
inherit system;
src = pkgs.fetchurl {
url = "${mirror}apt/ubuntu/dists/focal/mongodb-org/${major}.${minor}/multiverse/binary-${arch}/mongodb-org-server_${version}_${arch}.deb";
url = buildDownloadUrl system version;
sha256 = if pkgs.lib.hasAttr versionDetail sha256dict then pkgs.lib.getAttr versionDetail sha256dict else "";
};
# https://github.com/oxalica/rust-overlay/commit/c949d341f2b507857d589c48d1bd719896a2a224
depsHostHost = pkgs.lib.optional (!pkgs.hostPlatform.isDarwin) pkgs.gccForLibs.lib;
nativeBuildInputs = [
pkgs.autoPatchelfHook
pkgs.autoPatchelfHook
pkgs.dpkg
];
buildInputs = [
pkgs.openssl_1_1 # libcrypto.so.1.1 libssl.so.1.1
pkgs.xz # liblzma.so.5
pkgs.curl # libcurl.so.4
];
] ++ (if (pkgs.lib.strings.toInt major) <= 6 then [
pkgs.openssl_1_1 # libcrypto.so.1.1 libssl.so.1.1
] else [ ]);
unpackPhase = "true";
installPhase = ''
mkdir -p $out
Expand All @@ -52,7 +76,7 @@ in pkgs.stdenvNoCC.mkDerivation {
meta = {
description = "MongoDB";
homepage = https://www.mongodb.com/;
maintainers = [ "undefined <i@undefined.moe>" ];
maintainers = with pkgs.lib.maintainers; [ undefined-moe ];
platforms = [ system ];
};
}
}

0 comments on commit 56c8af1

Please sign in to comment.