mongodb-compass: add darwin support and split package file

Moved most of the package.nix code into linux.nix and introduced darwin.nix,
enabling mongodb-compass on x86_64-darwin and aarch64-darwin.

iamanaws 2c14a3e7 e3b579be

+210 -132
+63
pkgs/by-name/mo/mongodb-compass/darwin.nix
···
··· 1 + { 2 + stdenvNoCC, 3 + fetchurl, 4 + unzip, 5 + runtimeShell, 6 + pname, 7 + version, 8 + meta, 9 + }: 10 + 11 + let 12 + appName = "MongoDB Compass.app"; 13 + 14 + dist = 15 + { 16 + aarch64-darwin = { 17 + arch = "arm64"; 18 + sha256 = "sha256-naSOCYxdDLt/zDtR4MhTE96gJypfbk98CWKx2i8kiTk="; 19 + }; 20 + 21 + x86_64-darwin = { 22 + arch = "x64"; 23 + sha256 = "sha256-TnoXaiSNYiblgJS5nygTHOe9HBgVCTfffX37wrwtxZ8="; 24 + }; 25 + } 26 + .${stdenvNoCC.hostPlatform.system} 27 + or (throw "Unsupported system: ${stdenvNoCC.hostPlatform.system}"); 28 + 29 + in 30 + stdenvNoCC.mkDerivation { 31 + inherit pname version meta; 32 + 33 + src = fetchurl { 34 + url = "https://downloads.mongodb.com/compass/mongodb-compass-${version}-darwin-${dist.arch}.zip"; 35 + inherit (dist) sha256; 36 + name = "${pname}-${version}.zip"; 37 + }; 38 + 39 + nativeBuildInputs = [ unzip ]; 40 + 41 + # The archive will be automatically unzipped; tell Nix where the source root is. 42 + dontFixup = true; 43 + sourceRoot = appName; 44 + 45 + installPhase = '' 46 + runHook preInstall 47 + 48 + # Create directories for the application bundle and the launcher script. 49 + mkdir -p "$out/Applications/${appName}" "$out/bin" 50 + 51 + # Copy the unzipped app bundle into the Applications folder. 52 + cp -R . "$out/Applications/${appName}" 53 + 54 + # Create a launcher script that opens the app. 55 + cat > "$out/bin/${pname}" << EOF 56 + #!${runtimeShell} 57 + open -na "$out/Applications/${appName}" --args "\$@" 58 + EOF 59 + chmod +x "$out/bin/${pname}" 60 + 61 + runHook postInstall 62 + ''; 63 + }
+132
pkgs/by-name/mo/mongodb-compass/linux.nix
···
··· 1 + { 2 + alsa-lib, 3 + at-spi2-atk, 4 + at-spi2-core, 5 + atk, 6 + cairo, 7 + cups, 8 + curl, 9 + dbus, 10 + dpkg, 11 + expat, 12 + fetchurl, 13 + fontconfig, 14 + freetype, 15 + gdk-pixbuf, 16 + glib, 17 + gtk3, 18 + lib, 19 + libdrm, 20 + libGL, 21 + libnotify, 22 + libsecret, 23 + libuuid, 24 + libxcb, 25 + libxkbcommon, 26 + libgbm, 27 + nspr, 28 + nss, 29 + pango, 30 + stdenv, 31 + systemd, 32 + wrapGAppsHook3, 33 + xorg, 34 + pname, 35 + version, 36 + meta, 37 + }: 38 + 39 + let 40 + rpath = lib.makeLibraryPath [ 41 + alsa-lib 42 + at-spi2-atk 43 + at-spi2-core 44 + atk 45 + cairo 46 + cups 47 + curl 48 + dbus 49 + expat 50 + fontconfig 51 + freetype 52 + gdk-pixbuf 53 + glib 54 + gtk3 55 + libdrm 56 + libGL 57 + libnotify 58 + libsecret 59 + libuuid 60 + libxcb 61 + libxkbcommon 62 + libgbm 63 + nspr 64 + nss 65 + pango 66 + stdenv.cc.cc 67 + systemd 68 + xorg.libX11 69 + xorg.libXScrnSaver 70 + xorg.libXcomposite 71 + xorg.libXcursor 72 + xorg.libXdamage 73 + xorg.libXext 74 + xorg.libXfixes 75 + xorg.libXi 76 + xorg.libXrandr 77 + xorg.libXrender 78 + xorg.libXtst 79 + xorg.libxkbfile 80 + xorg.libxshmfence 81 + (lib.getLib stdenv.cc.cc) 82 + ]; 83 + 84 + in 85 + stdenv.mkDerivation { 86 + inherit pname version meta; 87 + 88 + src = 89 + if stdenv.hostPlatform.system == "x86_64-linux" then 90 + fetchurl { 91 + url = "https://downloads.mongodb.com/compass/mongodb-compass_${version}_amd64.deb"; 92 + hash = "sha256-cwhYiV5G8GRBT7MST20MPUxEMQM1mzxlLUfzGO6jv10="; 93 + } 94 + else 95 + throw "MongoDB compass is not supported on ${stdenv.hostPlatform.system}"; 96 + 97 + buildInputs = [ 98 + dpkg 99 + wrapGAppsHook3 100 + gtk3 101 + ]; 102 + dontUnpack = true; 103 + 104 + buildCommand = '' 105 + IFS=$'\n' 106 + 107 + # The deb file contains a setuid binary, so 'dpkg -x' doesn't work here 108 + dpkg --fsys-tarfile $src | tar --extract 109 + 110 + mkdir -p $out 111 + mv usr/* $out 112 + 113 + # cp -av $out/usr/* $out 114 + rm -rf $out/share/lintian 115 + 116 + # The node_modules are bringing in non-linux files/dependencies 117 + find $out -name "*.app" -exec rm -rf {} \; || true 118 + find $out -name "*.dll" -delete 119 + find $out -name "*.exe" -delete 120 + 121 + # Otherwise it looks "suspicious" 122 + chmod -R g-w $out 123 + 124 + for file in `find $out -type f -perm /0111 -o -name \*.so\*`; do 125 + echo "Manipulating file: $file" 126 + patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true 127 + patchelf --set-rpath ${rpath}:$out/lib/mongodb-compass "$file" || true 128 + done 129 + 130 + wrapGAppsHook $out/bin/mongodb-compass 131 + ''; 132 + }
+15 -132
pkgs/by-name/mo/mongodb-compass/package.nix
··· 1 { 2 - alsa-lib, 3 - at-spi2-atk, 4 - at-spi2-core, 5 - atk, 6 - cairo, 7 - cups, 8 - curl, 9 - dbus, 10 - dpkg, 11 - expat, 12 - fetchurl, 13 - fontconfig, 14 - freetype, 15 - gdk-pixbuf, 16 - glib, 17 - gtk3, 18 lib, 19 - libdrm, 20 - libGL, 21 - libnotify, 22 - libsecret, 23 - libuuid, 24 - libxcb, 25 - libxkbcommon, 26 - libgbm, 27 - nspr, 28 - nss, 29 - pango, 30 - stdenv, 31 - systemd, 32 - wrapGAppsHook3, 33 - xorg, 34 }: 35 36 let 37 version = "1.46.0"; 38 - 39 - rpath = lib.makeLibraryPath [ 40 - alsa-lib 41 - at-spi2-atk 42 - at-spi2-core 43 - atk 44 - cairo 45 - cups 46 - curl 47 - dbus 48 - expat 49 - fontconfig 50 - freetype 51 - gdk-pixbuf 52 - glib 53 - gtk3 54 - libdrm 55 - libGL 56 - libnotify 57 - libsecret 58 - libuuid 59 - libxcb 60 - libxkbcommon 61 - libgbm 62 - nspr 63 - nss 64 - pango 65 - stdenv.cc.cc 66 - systemd 67 - xorg.libX11 68 - xorg.libXScrnSaver 69 - xorg.libXcomposite 70 - xorg.libXcursor 71 - xorg.libXdamage 72 - xorg.libXext 73 - xorg.libXfixes 74 - xorg.libXi 75 - xorg.libXrandr 76 - xorg.libXrender 77 - xorg.libXtst 78 - xorg.libxkbfile 79 - xorg.libxshmfence 80 - (lib.getLib stdenv.cc.cc) 81 - ]; 82 - 83 - src = 84 - if stdenv.hostPlatform.system == "x86_64-linux" then 85 - fetchurl { 86 - url = "https://downloads.mongodb.com/compass/mongodb-compass_${version}_amd64.deb"; 87 - hash = "sha256-cwhYiV5G8GRBT7MST20MPUxEMQM1mzxlLUfzGO6jv10="; 88 - } 89 - else 90 - throw "MongoDB compass is not supported on ${stdenv.hostPlatform.system}"; 91 - # NOTE While MongoDB Compass is available to darwin, I do not have resources to test it 92 - # Feel free to make a PR adding support if desired 93 - 94 - in 95 - stdenv.mkDerivation { 96 - pname = "mongodb-compass"; 97 - inherit version; 98 - 99 - inherit src; 100 - 101 - buildInputs = [ 102 - dpkg 103 - wrapGAppsHook3 104 - gtk3 105 - ]; 106 - dontUnpack = true; 107 - 108 - buildCommand = '' 109 - IFS=$'\n' 110 - 111 - # The deb file contains a setuid binary, so 'dpkg -x' doesn't work here 112 - dpkg --fsys-tarfile $src | tar --extract 113 - 114 - mkdir -p $out 115 - mv usr/* $out 116 - 117 - # cp -av $out/usr/* $out 118 - rm -rf $out/share/lintian 119 - 120 - # The node_modules are bringing in non-linux files/dependencies 121 - find $out -name "*.app" -exec rm -rf {} \; || true 122 - find $out -name "*.dll" -delete 123 - find $out -name "*.exe" -delete 124 - 125 - # Otherwise it looks "suspicious" 126 - chmod -R g-w $out 127 - 128 - for file in `find $out -type f -perm /0111 -o -name \*.so\*`; do 129 - echo "Manipulating file: $file" 130 - patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true 131 - patchelf --set-rpath ${rpath}:$out/lib/mongodb-compass "$file" || true 132 - done 133 - 134 - wrapGAppsHook $out/bin/mongodb-compass 135 - ''; 136 - 137 meta = { 138 description = "GUI for MongoDB"; 139 maintainers = with lib.maintainers; [ 140 bryanasdev000 141 friedow 142 ]; 143 homepage = "https://github.com/mongodb-js/compass"; 144 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; 145 license = lib.licenses.sspl; 146 - platforms = [ "x86_64-linux" ]; 147 mainProgram = "mongodb-compass"; 148 }; 149 - }
··· 1 { 2 + stdenv, 3 + callPackage, 4 lib, 5 + ... 6 }: 7 8 let 9 + pname = "mongodb-compass"; 10 version = "1.46.0"; 11 meta = { 12 description = "GUI for MongoDB"; 13 maintainers = with lib.maintainers; [ 14 bryanasdev000 15 friedow 16 + iamanaws 17 ]; 18 homepage = "https://github.com/mongodb-js/compass"; 19 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; 20 license = lib.licenses.sspl; 21 + platforms = [ 22 + "x86_64-linux" 23 + "aarch64-darwin" 24 + "x86_64-darwin" 25 + ]; 26 mainProgram = "mongodb-compass"; 27 }; 28 + in 29 + if stdenv.hostPlatform.isDarwin then 30 + callPackage ./darwin.nix { inherit pname version meta; } 31 + else 32 + callPackage ./linux.nix { inherit pname version meta; }