|
| 1 | +{ |
| 2 | + lib, |
| 3 | + stdenv, |
| 4 | + boost, |
| 5 | + fetchFromGitHub, |
| 6 | + installShellFiles, |
| 7 | + muparser, |
| 8 | + pkg-config, |
| 9 | + qt5, |
| 10 | +}: |
| 11 | + |
| 12 | +stdenv.mkDerivation (finalAttrs: { |
| 13 | + pname = "librecad"; |
| 14 | + version = "2.2.1"; |
| 15 | + |
| 16 | + src = fetchFromGitHub { |
| 17 | + owner = "LibreCAD"; |
| 18 | + repo = "LibreCAD"; |
| 19 | + tag = "v${finalAttrs.version}"; |
| 20 | + hash = "sha256-GBn4lduzaKWEWzeTNjC9TpioSouVj+jVl32PLjc8FBc="; |
| 21 | + }; |
| 22 | + |
| 23 | + buildInputs = [ |
| 24 | + boost |
| 25 | + muparser |
| 26 | + qt5.qtbase |
| 27 | + qt5.qtsvg |
| 28 | + ]; |
| 29 | + |
| 30 | + nativeBuildInputs = [ |
| 31 | + installShellFiles |
| 32 | + pkg-config |
| 33 | + qt5.qmake |
| 34 | + qt5.qttools |
| 35 | + qt5.wrapQtAppsHook |
| 36 | + ]; |
| 37 | + |
| 38 | + qmakeFlags = [ |
| 39 | + "MUPARSER_DIR=${muparser}" |
| 40 | + "BOOST_DIR=${boost.dev}" |
| 41 | + ]; |
| 42 | + |
| 43 | + postPatch = '' |
| 44 | + substituteInPlace librecad/src/main/qc_applicationwindow.cpp \ |
| 45 | + --replace-warn __DATE__ 0 |
| 46 | +
|
| 47 | + substituteInPlace librecad/src/src.pro \ |
| 48 | + --replace-warn '$$[QT_INSTALL_BINS]' '${lib.getDev qt5.qttools}/bin' |
| 49 | + substituteInPlace librecad/src/muparser.pri \ |
| 50 | + --replace-warn "macx|" "" |
| 51 | + ''; |
| 52 | + |
| 53 | + installPhase = '' |
| 54 | + runHook preInstall |
| 55 | +
|
| 56 | + ${lib.optionalString stdenv.hostPlatform.isDarwin '' |
| 57 | + mkdir -p $out/{Applications,bin} |
| 58 | + mv LibreCAD.app $out/Applications |
| 59 | + ln -s $out/Applications/LibreCAD.app/Contents/MacOS/LibreCAD $out/bin/librecad |
| 60 | + # Prevent wrapping, otherwise plugins will not be loaded |
| 61 | + chmod -x $out/Applications/LibreCAD.app/Contents/Resources/plugins/*.dylib |
| 62 | + ''} |
| 63 | +
|
| 64 | + ${lib.optionalString (!stdenv.hostPlatform.isDarwin) '' |
| 65 | + install -Dm555 -t $out/bin unix/{librecad,ttf2lff} |
| 66 | + install -Dm444 -t $out/share/applications desktop/librecad.desktop |
| 67 | + install -Dm644 -t $out/share/pixmaps librecad/res/main/librecad.png |
| 68 | + install -Dm444 desktop/librecad.sharedmimeinfo $out/share/mime/packages/librecad.xml |
| 69 | + install -Dm444 desktop/graphics_icons_and_splash/Icon\ LibreCAD/Icon_Librecad.svg \ |
| 70 | + $out/share/icons/hicolor/scalable/apps/librecad.svg |
| 71 | +
|
| 72 | + installManPage desktop/librecad.? |
| 73 | +
|
| 74 | + cp -R unix/resources $out/share/librecad |
| 75 | + ''} |
| 76 | +
|
| 77 | + runHook postInstall |
| 78 | + ''; |
| 79 | + |
| 80 | + meta = { |
| 81 | + description = "2D CAD package based on Qt"; |
| 82 | + homepage = "https://librecad.org"; |
| 83 | + license = lib.licenses.gpl2Only; |
| 84 | + maintainers = with lib.maintainers; [ sikmir ]; |
| 85 | + platforms = lib.platforms.unix; |
| 86 | + mainProgram = "librecad"; |
| 87 | + }; |
| 88 | +}) |
0 commit comments