Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 fetchzip, 5 fetchurl, 6 autoPatchelfHook, 7 makeWrapper, 8 makeDesktopItem, 9 cups, 10 qt5, 11 undmg, 12}: 13 14stdenv.mkDerivation (finalAttrs: { 15 pname = "010editor"; 16 version = "15.0.2"; 17 18 src = 19 if stdenv.hostPlatform.isLinux then 20 fetchzip { 21 url = "https://download.sweetscape.com/010EditorLinux64Installer${finalAttrs.version}.tar.gz"; 22 hash = "sha256-oXwC4criDox8rac7mnJroqxMNKU7k+y7JQqc88XoRFc="; 23 } 24 else 25 fetchurl { 26 url = "https://download.sweetscape.com/010EditorMac64Installer${finalAttrs.version}.dmg"; 27 hash = "sha256-RZtFV3AbE5KfzW18usW0FS/AnX8Uets/RkVayBAODQ4="; 28 }; 29 30 sourceRoot = "."; 31 32 strictDeps = true; 33 dontBuild = true; 34 dontConfigure = true; 35 36 nativeBuildInputs = 37 lib.optionals stdenv.hostPlatform.isLinux [ 38 autoPatchelfHook 39 makeWrapper 40 qt5.wrapQtAppsHook 41 ] 42 ++ lib.optionals stdenv.hostPlatform.isDarwin [ undmg ]; 43 44 buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ 45 cups 46 qt5.qtbase 47 qt5.qtwayland 48 ]; 49 50 installPhase = 51 let 52 darwinInstall = '' 53 mkdir -p $out/Applications 54 cp -R *.app $out/Applications 55 ''; 56 linuxInstall = '' 57 mkdir -p $out/opt && cp -ar source/* $out/opt 58 59 # Unset wrapped QT plugins since they're already included in the package, 60 # else the program crashes because of the conflict 61 makeWrapper $out/opt/010editor $out/bin/010editor \ 62 --unset QT_PLUGIN_PATH 63 64 # Copy the icon and generated desktop file 65 install -D $out/opt/010_icon_128x128.png $out/share/icons/hicolor/128x128/apps/010.png 66 install -D $desktopItem/share/applications/* -t $out/share/applications/ 67 ''; 68 in 69 '' 70 runHook preInstall 71 ${ 72 if stdenv.hostPlatform.isDarwin then 73 darwinInstall 74 else if stdenv.hostPlatform.isLinux then 75 linuxInstall 76 else 77 "echo 'Unsupported Platform' && exit 1" 78 } 79 runHook postInstall 80 ''; 81 82 desktopItem = makeDesktopItem { 83 name = "010editor"; 84 exec = "010editor %f"; 85 icon = "010"; 86 desktopName = "010 Editor"; 87 genericName = "Text and hex edtior"; 88 categories = [ "Development" ]; 89 mimeTypes = [ 90 "text/html" 91 "text/plain" 92 "text/x-c++hdr" 93 "text/x-c++src" 94 "text/xml" 95 ]; 96 }; 97 98 meta = { 99 description = "Text and hex editor"; 100 homepage = "https://www.sweetscape.com/010editor/"; 101 license = lib.licenses.unfree; 102 maintainers = with lib.maintainers; [ eljamm ]; 103 platforms = [ 104 "aarch64-darwin" 105 "x86_64-darwin" 106 "x86_64-linux" 107 ]; 108 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; 109 mainProgram = "010editor"; 110 }; 111})