summaryrefslogtreecommitdiff
path: root/pkgs/applications/graphics/leocad/default.nix
blob: 49ee98e95d8fba2718ca42bba11d18d51e53d912 (about) (plain)
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
{
  lib,
  stdenv,
  fetchFromGitHub,
  fetchurl,
  povray,
  qmake,
  qttools,
  replaceVars,
  zlib,
  testers,
  wrapQtAppsHook,
  nix-update-script,
  libGL,
}:

/*
  To use additional parts libraries
  set the variable LEOCAD_LIB=/path/to/libs/ or use option -l /path/to/libs/
*/

let
  parts = fetchurl {
    url = "https://web.archive.org/web/20241230062818/https://library.ldraw.org/library/updates/complete.zip";
    hash = "sha256-0RIJYEU+MpE4MSfxk2HK5hQd8IsiPn2xEGUFmItzlk8=";
  };

in
stdenv.mkDerivation (finalAttrs: {
  pname = "leocad";
  version = "23.03";

  src = fetchFromGitHub {
    owner = "leozide";
    repo = "leocad";
    tag = "v${finalAttrs.version}";
    hash = "sha256-IY9mr2gSMZL9pxiVTKH/f7rjsOvBDNgwVKpXA57oMGo=";
  };

  nativeBuildInputs = [
    qmake
    qttools
    wrapQtAppsHook
  ];

  buildInputs = [
    zlib
    libGL
  ];

  propagatedBuildInputs = [ povray ];

  patches = [
    (replaceVars ./povray.patch {
      inherit povray;
    })
  ];

  qmakeFlags = [
    "INSTALL_PREFIX=${placeholder "out"}"
    "DISABLE_UPDATE_CHECK=1"
  ];

  qtWrapperArgs = [
    "--set-default LEOCAD_LIB ${parts}"
  ];

  passthru = {
    tests.version = testers.testVersion {
      package = finalAttrs.finalPackage;
      command = "env QT_QPA_PLATFORM=minimal ${lib.getExe finalAttrs.finalPackage} --version";
    };
    updateScript = nix-update-script { };
  };

  passthru = {
    description = "CAD program for creating virtual LEGO models";
    mainProgram = "leocad";
    homepage = "https://www.leocad.org/";
    license = lib.licenses.gpl2Only;
    maintainers = with lib.maintainers; [
      peterhoeg
    ];
    platforms = lib.platforms.linux;
  };
})