about summary refs log tree commit diff
path: root/pkgs/by-name/id/ideamaker/package.nix
blob: 8818869b6036730302f45c9bb75e66cdfd7c1464 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
{
  stdenv,
  autoPatchelfHook,
  cacert,
  common-updater-scripts,
  curl,
  dpkg,
  fetchurl,
  fetchzip,
  lib,
  libcork,
  libGLU,
  libsForQt5,
  makeDesktopItem,
  openssl,
  shared-mime-info,
  writeShellApplication,
}:
stdenv.mkDerivation (finalAttrs: {
  pname = "ideamaker";
  version = "4.3.3.6560";
  src =
    let
      semver = lib.strings.concatStringsSep "." (
        lib.lists.init (builtins.splitVersion finalAttrs.version)
      );
    in
    fetchurl {
      url = "https://download.raise3d.com/ideamaker/release/${semver}/ideaMaker_${finalAttrs.version}-ubuntu_amd64.deb";
      sha256 = "sha256-aTVWCTgnVKD16uhJUVz0vR7KPGJqCVj0xoL53Qi3IKM=";
    };

  nativeBuildInputs = [
    autoPatchelfHook
    dpkg
    shared-mime-info
    libsForQt5.wrapQtAppsHook
  ];

  buildInputs =
    let
      # we need curl 7.47.0, as the app segfaults on launch in 7.47.1 and beyond
      # (tested with 7.47.1, 7.50.3, 7.62, 7.79.1, and 8.7.1)
      curl_7_47_0 =
        let
          openssl_1_0_1u = openssl.overrideAttrs (previous: {
            version = "1.0.1u";
            src = fetchurl {
              url = "https://www.openssl.org/source/openssl-1.0.1u.tar.gz";
              sha256 = "0fb7y9pwbd76pgzd7xzqfrzibmc0vf03sl07f34z5dhm2b5b84j3";
            };
            patches = [ ];
            withDocs = false;
            outputs = lib.lists.remove "doc" previous.outputs;
            meta.knownVulnerabilities = [
              "OpenSSL 1.0.1 reached its end of life 2016-12-31, see https://endoflife.software/applications/security-libraries/openssl."
              "CVE-2021-4044"
              "CVE-2016-7056"
            ];
          });
        in
        (curl.override {
          gnutlsSupport = true;
          gssSupport = false;
          http2Support = false;
          # while we use openssl, the configureFlag has since changed, so we manually set it below
          opensslSupport = false;
          pslSupport = false;
          scpSupport = false;
        }).overrideAttrs
          (previous: {
            version = "7.47.0";
            src = fetchzip {
              url = "https://curl.se/download/curl-7.47.0.tar.lzma";
              sha256 = "sha256-XlZk1nJbSmiQp7jMSE2QRCY4C9w2us8BgosBSzlD4dE=";
            };
            configureFlags = previous.configureFlags ++ [
              "--with-ca-bundle=${cacert}/etc/ssl/certs/ca-bundle.crt"
              "--with-ssl=${lib.getLib openssl_1_0_1u}"
            ];
            patches = [ ];
            # curl https://curl.se/docs/vuln-7.74.0.json | jq -r '.[].id' | sed 's/^/"/;s/$/"/'
            meta.knownVulnerabilities = [
              "CURL-CVE-2024-2398"
              "CURL-CVE-2023-46218"
              "CURL-CVE-2023-38546"
              "CURL-CVE-2023-38545"
              "CURL-CVE-2023-28322"
              "CURL-CVE-2023-28321"
              "CURL-CVE-2023-28320"
              "CURL-CVE-2023-27538"
              "CURL-CVE-2023-27536"
              "CURL-CVE-2023-27535"
              "CURL-CVE-2023-27534"
              "CURL-CVE-2023-27533"
              "CURL-CVE-2023-23916"
              "CURL-CVE-2022-43552"
              "CURL-CVE-2022-32221"
              "CURL-CVE-2022-35252"
              "CURL-CVE-2022-32208"
              "CURL-CVE-2022-32207"
              "CURL-CVE-2022-32206"
              "CURL-CVE-2022-32205"
              "CURL-CVE-2022-27782"
              "CURL-CVE-2022-27781"
              "CURL-CVE-2022-27776"
              "CURL-CVE-2022-27775"
              "CURL-CVE-2022-27774"
              "CURL-CVE-2022-22576"
              "CURL-CVE-2021-22947"
              "CURL-CVE-2021-22946"
              "CURL-CVE-2021-22945"
              "CURL-CVE-2021-22926"
              "CURL-CVE-2021-22925"
              "CURL-CVE-2021-22924"
              "CURL-CVE-2021-22923"
              "CURL-CVE-2021-22922"
              "CURL-CVE-2021-22898"
              "CURL-CVE-2021-22897"
              "CURL-CVE-2021-22890"
              "CURL-CVE-2021-22876"
            ];
          });
    in
    [
      (lib.getLib curl_7_47_0)
      libcork
      libGLU
      libsForQt5.qtbase
      libsForQt5.qtserialport
      libsForQt5.quazip
    ];

  unpackPhase = ''
    runHook preUnpack
    dpkg-deb -x $src .
    runHook postUnpack
  '';

  installPhase = ''
    runHook preInstall

    install -D usr/lib/x86_64-linux-gnu/ideamaker/ideamaker \
      $out/bin/${finalAttrs.pname}

    patchelf --replace-needed libquazip.so.1 libquazip1-qt5.so \
      $out/bin/${finalAttrs.pname}

    mimetypeDir=$out/share/icons/hicolor/128x128/mimetypes
    mkdir -p ''$mimetypeDir
    for file in usr/share/ideamaker/icons/*.ico; do
      mv $file ''$mimetypeDir/''$(basename ''${file%.ico}).png
    done
    install -D ${./mimetypes.xml} \
      $out/share/mime/packages/${finalAttrs.pname}.xml

    install -D usr/share/ideamaker/icons/ideamaker-icon.png \
      $out/share/pixmaps/${finalAttrs.pname}.png

    ln -s ${finalAttrs.desktopItem}/share/applications $out/share/

    runHook postInstall
  '';

  desktopItem = makeDesktopItem {
    name = finalAttrs.pname;
    exec = finalAttrs.pname;
    icon = finalAttrs.pname;
    desktopName = "Ideamaker";
    comment = "ideaMaker - www.raise3d.com";
    categories = [
      "Qt"
      "Utility"
      "3DGraphics"
      "Viewer"
      "Engineering"
    ];
    genericName = finalAttrs.meta.description;
    mimeTypes = [
      "application/x-ideamaker"
      "model/3mf"
      "model/obj"
      "model/stl"
      "text/x.gcode"
    ];
    noDisplay = false;
    startupNotify = true;
    terminal = false;
    type = "Application";
  };

  passthru.updateScript = lib.getExe (writeShellApplication {
    name = "ideamaker-update-script";
    runtimeInputs = [
      curl
      common-updater-scripts
    ];
    text = ''
      set -eu -o pipefail

      release_page=$(mktemp)
      curl -s https://www.raise3d.com/download/ideamaker-all-versions/ > "$release_page"

      latest_stable_version=$(
        sed -nE '/Beta|Alpha/! s/.*Version ([0-9]+\.[0-9]+\.[0-9]+).*/\1/p' "$release_page" | \
          head -n 1
      )

      latest_stable_build_number=$(
        sed -nE "s/.*ideaMaker_$latest_stable_version\.([0-9]+).*/\1/p" "$release_page" | head -n 1
      )

      update-source-version ideamaker "$latest_stable_version.$latest_stable_build_number"
    '';
  });

  meta = {
    homepage = "https://www.raise3d.com/ideamaker/";
    description = "Raise3D's 3D slicer software";
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
    license = lib.licenses.unfree;
    platforms = [ "x86_64-linux" ];
    maintainers = with lib.maintainers; [ cjshearer ];
  };
})