diff --git a/default.nix b/default.nix index 79ed95e..4eef45e 100644 --- a/default.nix +++ b/default.nix @@ -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; }; diff --git a/flake.nix b/flake.nix index 5407515..a89e70f 100644 --- a/flake.nix +++ b/flake.nix @@ -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; }; } ); } diff --git a/mongodb.nix b/mongodb.nix index 1555c4b..8fa1976 100644 --- a/mongodb.nix +++ b/mongodb.nix @@ -1,46 +1,70 @@ -{ - system ? builtins.currentSystem, - pkgs ? import { system = system; }, - version ? "5.0.6", - mirror ? "https://repo.mongodb.org/" +{ system ? builtins.currentSystem +, pkgs ? import { 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 @@ -52,7 +76,7 @@ in pkgs.stdenvNoCC.mkDerivation { meta = { description = "MongoDB"; homepage = https://www.mongodb.com/; - maintainers = [ "undefined " ]; + maintainers = with pkgs.lib.maintainers; [ undefined-moe ]; platforms = [ system ]; }; -} \ No newline at end of file +}