nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 131 lines 4.0 kB view raw
1{ 2 lib, 3 stdenv, 4 stdenvNoCC, 5 fetchurl, 6 writeScriptBin, 7 appimageTools, 8 copyDesktopItems, 9 makeDesktopItem, 10 nix-update-script, 11 wrapGAppsHook3, 12}: 13 14stdenvNoCC.mkDerivation rec { 15 pname = "cura-appimage"; 16 version = "5.11.0"; 17 18 # Give some good names so the intermediate packages are easy 19 # to recognise by name in the Nix store. 20 appimageBinName = "cura-appimage-tools-output"; 21 wrapperScriptName = "${pname}-wrapper-script"; 22 23 src = fetchurl { 24 url = "https://github.com/Ultimaker/Cura/releases/download/${version}/Ultimaker-Cura-${version}-linux-X64.AppImage"; 25 hash = "sha256-us375gxVrGqGem2Et2VNRm6T389JxzPm1TScerlia9k="; 26 }; 27 28 appimageContents = appimageTools.extract { 29 inherit pname version src; 30 }; 31 32 curaAppimageToolsWrapped = appimageTools.wrapType2 { 33 inherit src; 34 # For `appimageTools.wrapType2`, `pname` determines the binary's name in `bin/`. 35 pname = appimageBinName; 36 inherit version; 37 extraPkgs = _: [ ]; 38 }; 39 40 # The `QT_QPA_PLATFORM=xcb` fixes Wayland support, see https://github.com/NixOS/nixpkgs/issues/186570#issuecomment-2526277637 41 # The `GTK_USE_PORTAL=1` fixes file dialog issues under Gnome, see https://github.com/NixOS/nixpkgs/pull/372614#issuecomment-2585663161 42 script = writeScriptBin wrapperScriptName '' 43 #!${stdenv.shell} 44 # AppImage version of Cura loses current working directory and treats all paths relateive to $HOME. 45 # So we convert each of the files passed as argument to an absolute path. 46 # This fixes use cases like `cd /path/to/my/files; cura mymodel.stl anothermodel.stl`. 47 48 args=() 49 for a in "$@"; do 50 if [ -e "$a" ]; then 51 a="$(realpath "$a")" 52 fi 53 args+=("$a") 54 done 55 QT_QPA_PLATFORM=xcb GTK_USE_PORTAL=1 exec "${curaAppimageToolsWrapped}/bin/${appimageBinName}" "''${args[@]}" 56 ''; 57 58 dontUnpack = true; 59 60 nativeBuildInputs = [ 61 copyDesktopItems 62 wrapGAppsHook3 63 ]; 64 desktopItems = [ 65 # Based on upstream. 66 # https://github.com/Ultimaker/Cura/blob/382b98e8b0c910fdf8b1509557ae8afab38f1817/packaging/AppImage/cura.desktop.jinja 67 (makeDesktopItem { 68 name = "cura"; 69 desktopName = "UltiMaker Cura"; 70 genericName = "3D Printing Software"; 71 comment = meta.longDescription; 72 exec = "cura"; 73 icon = "cura-icon"; 74 terminal = false; 75 type = "Application"; 76 mimeTypes = [ 77 "model/stl" 78 "application/vnd.ms-3mfdocument" 79 "application/prs.wavefront-obj" 80 "image/bmp" 81 "image/gif" 82 "image/jpeg" 83 "image/png" 84 "text/x-gcode" 85 "application/x-amf" 86 "application/x-ply" 87 "application/x-ctm" 88 "model/vnd.collada+xml" 89 "model/gltf-binary" 90 "model/gltf+json" 91 "model/vnd.collada+xml+zip" 92 ]; 93 categories = [ "Graphics" ]; 94 keywords = [ 95 "3D" 96 "Printing" 97 ]; 98 }) 99 ]; 100 101 installPhase = '' 102 runHook preInstall 103 104 mkdir -p $out/bin 105 cp ${script}/bin/${wrapperScriptName} $out/bin/cura 106 107 mkdir -p $out/share/applications $out/share/icons/hicolor/128x128/apps 108 install -Dm644 ${appimageContents}/usr/share/icons/hicolor/128x128/apps/cura-icon.png $out/share/icons/hicolor/128x128/apps/cura-icon.png 109 110 runHook postInstall 111 ''; 112 113 passthru.updateScript = nix-update-script { extraArgs = [ "--version-regex=([56789].+)" ]; }; 114 115 meta = { 116 description = "3D printing software"; 117 homepage = "https://github.com/ultimaker/cura"; 118 changelog = "https://github.com/Ultimaker/Cura/releases/tag/${version}"; 119 longDescription = '' 120 Cura converts 3D models into paths for a 3D printer. It prepares your print for maximum accuracy, minimum printing time and good reliability with many extra features that make your print come out great. 121 ''; 122 license = lib.licenses.lgpl3Plus; 123 platforms = [ "x86_64-linux" ]; 124 mainProgram = "cura"; 125 maintainers = with lib.maintainers; [ 126 pbek 127 nh2 128 fliegendewurst 129 ]; 130 }; 131}