diff --git a/pkgs/by-name/mo/mongodb-compass/darwin.nix b/pkgs/by-name/mo/mongodb-compass/darwin.nix deleted file mode 100644 index b2036833d536..000000000000 --- a/pkgs/by-name/mo/mongodb-compass/darwin.nix +++ /dev/null @@ -1,63 +0,0 @@ -{ - stdenvNoCC, - fetchurl, - unzip, - runtimeShell, - pname, - version, - meta, -}: - -let - appName = "MongoDB Compass.app"; - - dist = - { - aarch64-darwin = { - arch = "arm64"; - sha256 = "sha256-naSOCYxdDLt/zDtR4MhTE96gJypfbk98CWKx2i8kiTk="; - }; - - x86_64-darwin = { - arch = "x64"; - sha256 = "sha256-TnoXaiSNYiblgJS5nygTHOe9HBgVCTfffX37wrwtxZ8="; - }; - } - .${stdenvNoCC.hostPlatform.system} - or (throw "Unsupported system: ${stdenvNoCC.hostPlatform.system}"); - -in -stdenvNoCC.mkDerivation { - inherit pname version meta; - - src = fetchurl { - url = "https://downloads.mongodb.com/compass/mongodb-compass-${version}-darwin-${dist.arch}.zip"; - inherit (dist) sha256; - name = "${pname}-${version}.zip"; - }; - - nativeBuildInputs = [ unzip ]; - - # The archive will be automatically unzipped; tell Nix where the source root is. - dontFixup = true; - sourceRoot = appName; - - installPhase = '' - runHook preInstall - - # Create directories for the application bundle and the launcher script. - mkdir -p "$out/Applications/${appName}" "$out/bin" - - # Copy the unzipped app bundle into the Applications folder. - cp -R . "$out/Applications/${appName}" - - # Create a launcher script that opens the app. - cat > "$out/bin/${pname}" << EOF - #!${runtimeShell} - open -na "$out/Applications/${appName}" --args "\$@" - EOF - chmod +x "$out/bin/${pname}" - - runHook postInstall - ''; -} diff --git a/pkgs/by-name/mo/mongodb-compass/linux.nix b/pkgs/by-name/mo/mongodb-compass/linux.nix deleted file mode 100644 index c3c4797bc501..000000000000 --- a/pkgs/by-name/mo/mongodb-compass/linux.nix +++ /dev/null @@ -1,132 +0,0 @@ -{ - alsa-lib, - at-spi2-atk, - at-spi2-core, - atk, - cairo, - cups, - curl, - dbus, - dpkg, - expat, - fetchurl, - fontconfig, - freetype, - gdk-pixbuf, - glib, - gtk3, - lib, - libdrm, - libGL, - libnotify, - libsecret, - libuuid, - libxcb, - libxkbcommon, - libgbm, - nspr, - nss, - pango, - stdenv, - systemd, - wrapGAppsHook3, - xorg, - pname, - version, - meta, -}: - -let - rpath = lib.makeLibraryPath [ - alsa-lib - at-spi2-atk - at-spi2-core - atk - cairo - cups - curl - dbus - expat - fontconfig - freetype - gdk-pixbuf - glib - gtk3 - libdrm - libGL - libnotify - libsecret - libuuid - libxcb - libxkbcommon - libgbm - nspr - nss - pango - stdenv.cc.cc - systemd - xorg.libX11 - xorg.libXScrnSaver - xorg.libXcomposite - xorg.libXcursor - xorg.libXdamage - xorg.libXext - xorg.libXfixes - xorg.libXi - xorg.libXrandr - xorg.libXrender - xorg.libXtst - xorg.libxkbfile - xorg.libxshmfence - (lib.getLib stdenv.cc.cc) - ]; - -in -stdenv.mkDerivation { - inherit pname version meta; - - src = - if stdenv.hostPlatform.system == "x86_64-linux" then - fetchurl { - url = "https://downloads.mongodb.com/compass/mongodb-compass_${version}_amd64.deb"; - hash = "sha256-cwhYiV5G8GRBT7MST20MPUxEMQM1mzxlLUfzGO6jv10="; - } - else - throw "MongoDB compass is not supported on ${stdenv.hostPlatform.system}"; - - buildInputs = [ - dpkg - wrapGAppsHook3 - gtk3 - ]; - dontUnpack = true; - - buildCommand = '' - IFS=$'\n' - - # The deb file contains a setuid binary, so 'dpkg -x' doesn't work here - dpkg --fsys-tarfile $src | tar --extract - - mkdir -p $out - mv usr/* $out - - # cp -av $out/usr/* $out - rm -rf $out/share/lintian - - # The node_modules are bringing in non-linux files/dependencies - find $out -name "*.app" -exec rm -rf {} \; || true - find $out -name "*.dll" -delete - find $out -name "*.exe" -delete - - # Otherwise it looks "suspicious" - chmod -R g-w $out - - for file in `find $out -type f -perm /0111 -o -name \*.so\*`; do - echo "Manipulating file: $file" - patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true - patchelf --set-rpath ${rpath}:$out/lib/mongodb-compass "$file" || true - done - - wrapGAppsHook $out/bin/mongodb-compass - ''; -} diff --git a/pkgs/by-name/mo/mongodb-compass/package.nix b/pkgs/by-name/mo/mongodb-compass/package.nix index d72641d627a6..d6a3587100d8 100644 --- a/pkgs/by-name/mo/mongodb-compass/package.nix +++ b/pkgs/by-name/mo/mongodb-compass/package.nix @@ -1,31 +1,192 @@ { - stdenv, - callPackage, lib, + stdenv, + fetchurl, + dpkg, + unzip, + wrapGAppsHook3, + makeWrapper, + runtimeShell, + gtk3, + xorg, + glib, + cairo, + pango, + dbus, + cups, + at-spi2-atk, + at-spi2-core, + atk, + libdrm, + gdk-pixbuf, + nss, + nspr, + alsa-lib, + expat, + libxkbcommon, + libgbm, + vulkan-loader, + systemd, + libGL, + krb5, + fontconfig, + freetype, + libnotify, + libsecret, + libuuid, + libxcb, + patchelf, }: let pname = "mongodb-compass"; - version = "1.46.0"; + version = "1.46.11"; + + selectSystem = + attrs: + attrs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); + + src = fetchurl { + url = "https://downloads.mongodb.com/compass/${ + selectSystem { + x86_64-linux = "mongodb-compass_${version}_amd64.deb"; + x86_64-darwin = "mongodb-compass-${version}-darwin-x64.zip"; + aarch64-darwin = "mongodb-compass-${version}-darwin-arm64.zip"; + } + }"; + hash = selectSystem { + x86_64-linux = "sha256-GelQnhrc68xEd4q4ZPgldCnbuLqYZ76LQbWi1LsvL9o="; + x86_64-darwin = "sha256-SiwwK7ApifjvCqBeVPtjnafKLKETnP8tegVfXaiCJ8c="; + aarch64-darwin = "sha256-g2X9zOk7rjuTFxXXX8t9kvjF11VknlIvjAhYU09fjBQ="; + }; + }; + + appName = "MongoDB Compass.app"; + + rpath = lib.makeLibraryPath [ + alsa-lib + at-spi2-atk + at-spi2-core + atk + cairo + cups + dbus + expat + fontconfig + freetype + gdk-pixbuf + glib + gtk3 + libdrm + libGL + libnotify + libsecret + libuuid + libxcb + libxkbcommon + libgbm + nspr + nss + pango + stdenv.cc.cc + systemd + xorg.libX11 + xorg.libXScrnSaver + xorg.libXcomposite + xorg.libXcursor + xorg.libXdamage + xorg.libXext + xorg.libXfixes + xorg.libXi + xorg.libXrandr + xorg.libXrender + xorg.libXtst + xorg.libxkbfile + xorg.libxshmfence + (lib.getLib stdenv.cc.cc) + ]; +in +stdenv.mkDerivation (finalAttrs: { + inherit pname version src; + + buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ + dpkg + wrapGAppsHook3 + patchelf + ]; + + nativeBuildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ unzip ]; + + dontUnpack = stdenv.hostPlatform.isLinux; + dontFixup = stdenv.hostPlatform.isDarwin; + sourceRoot = lib.optionalString stdenv.hostPlatform.isDarwin appName; + + buildCommand = lib.optionalString stdenv.hostPlatform.isLinux '' + IFS=$'\n' + + # The deb file contains a setuid binary, so 'dpkg -x' doesn't work here + dpkg --fsys-tarfile $src | tar --extract + + mkdir -p $out + mv usr/* $out + + rm -rf $out/share/lintian + + # The node_modules are bringing in non-linux files/dependencies + find $out -name "*.app" -exec rm -rf {} \; || true + find $out -name "*.dll" -delete + find $out -name "*.exe" -delete + + # Otherwise it looks "suspicious" + chmod -R g-w $out + + for file in `find $out -type f -perm /0111 -o -name \*.so\*`; do + echo "Manipulating file: $file" + patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true + patchelf --set-rpath ${rpath}:$out/lib/mongodb-compass "$file" || true + done + + wrapGAppsHook $out/bin/mongodb-compass + ''; + + installPhase = '' + runHook preInstall + + ${lib.optionalString stdenv.hostPlatform.isDarwin '' + # Create directories for the application bundle and the launcher script. + mkdir -p "$out/Applications/${appName}" "$out/bin" + + # Copy the unzipped app bundle into the Applications folder. + cp -R . "$out/Applications/${appName}" + + # Create a launcher script that opens the app. + cat > "$out/bin/${pname}" << EOF + #!${runtimeShell} + open -na "$out/Applications/${appName}" --args "\$@" + EOF + chmod +x "$out/bin/${pname}" + ''} + + runHook postInstall + ''; + + passthru.updateScript = ./update.sh; + meta = { description = "GUI for MongoDB"; + homepage = "https://github.com/mongodb-js/compass"; + license = lib.licenses.sspl; + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + mainProgram = "mongodb-compass"; maintainers = with lib.maintainers; [ bryanasdev000 friedow iamanaws ]; - homepage = "https://github.com/mongodb-js/compass"; - sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; - license = lib.licenses.sspl; platforms = [ "x86_64-linux" "aarch64-darwin" "x86_64-darwin" ]; - mainProgram = "mongodb-compass"; }; -in -if stdenv.hostPlatform.isDarwin then - callPackage ./darwin.nix { inherit pname version meta; } -else - callPackage ./linux.nix { inherit pname version meta; } +}) diff --git a/pkgs/by-name/mo/mongodb-compass/update.sh b/pkgs/by-name/mo/mongodb-compass/update.sh new file mode 100755 index 000000000000..3dcd381d73a3 --- /dev/null +++ b/pkgs/by-name/mo/mongodb-compass/update.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p nix curl jq common-updater-scripts + +set -eou pipefail + +latestVersion=$(curl -s https://api.github.com/repos/mongodb-js/compass/releases/latest | jq -r .tag_name | sed 's/^v//') + +if [[ "$latestVersion" == "$UPDATE_NIX_OLD_VERSION" ]]; then + echo "mongodb-compass is already up-to-date: $latestVersion" + exit 0 +fi + +update-source-version mongodb-compass "$latestVersion" + +systems=$(nix eval --json -f . mongodb-compass.meta.platforms | jq -r '.[]') +for system in $systems; do + url=$(nix eval --raw -f . mongodb-compass.src.url --system "$system") + hash=$(nix --extra-experimental-features nix-command hash convert --to sri --hash-algo sha256 $(nix-prefetch-url "$url")) + update-source-version mongodb-compass "$latestVersion" "$hash" --system=$system --ignore-same-version --ignore-same-hash +done