about summary refs log tree commit diff
path: root/nixpkgs/pkgs/by-name/ja/jasp-desktop/package.nix
blob: 395b980da880fc5808a821db4117cf5a2edeb3a7 (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
{ lib
, stdenv
, fetchFromGitHub
, callPackage
, buildEnv
, linkFarm
, substituteAll
, R
, rPackages
, cmake
, ninja
, pkg-config
, boost
, libarchive
, readstat
, qt6
}:

let
  version = "0.18.3";

  src = fetchFromGitHub {
    owner = "jasp-stats";
    repo = "jasp-desktop";
    rev = "v${version}";
    hash = "sha256-eKBxCIamNhUig+0vUEqXYbPjiaOsZk6QnOw8cnpjKFY=";
    fetchSubmodules = true;
  };

  inherit (callPackage ./modules.nix {
    jasp-src = src;
    jasp-version = version;
  }) engine modules;

  # Merges ${R}/lib/R with all used R packages (even propagated ones)
  customREnv = buildEnv {
    name = "jasp-${version}-env";
    paths = [
      "${R}/lib/R"
      rPackages.RInside
      engine.jaspBase # Should already be propagated from modules, but include it again, just in case
    ] ++ lib.attrValues modules;
  };

  modulesDir = linkFarm "jasp-${version}-modules"
    (lib.mapAttrsToList (name: drv: { name = name; path = "${drv}/library"; }) modules);
in
stdenv.mkDerivation {
  pname = "jasp-desktop";
  inherit version src;

  patches = [
    # remove unused cmake deps, ensure boost is dynamically linked, patch readstat path
    (substituteAll {
      src = ./cmake.patch;
      inherit readstat;
    })
  ];

  cmakeFlags = [
    "-DGITHUB_PAT=dummy"
    "-DGITHUB_PAT_DEF=dummy"
    "-DINSTALL_R_FRAMEWORK=OFF"
    "-DLINUX_LOCAL_BUILD=OFF"
    "-DINSTALL_R_MODULES=OFF"
    "-DCUSTOM_R_PATH=${customREnv}"
  ];

  nativeBuildInputs = [
    cmake
    ninja
    pkg-config
    qt6.wrapQtAppsHook
  ];

  buildInputs = [
    customREnv
    boost
    libarchive
    readstat
  ] ++ (with qt6; [
    qtbase
    qtdeclarative
    qtwebengine
    qtsvg
    qt5compat
  ]);

  env.NIX_LDFLAGS = "-L${rPackages.RInside}/library/RInside/lib";

  postInstall = ''
    # Remove unused cache locations
    rm -r $out/lib64 $out/Modules

    # Remove flatpak proxy script
    rm $out/bin/org.jaspstats.JASP
    substituteInPlace $out/share/applications/org.jaspstats.JASP.desktop \
        --replace "Exec=org.jaspstats.JASP" "Exec=JASP"

    # symlink modules from the store
    ln -s ${modulesDir} $out/Modules
  '';

  passthru = {
    inherit modules engine;
    env = customREnv;
  };

  meta = {
    changelog = "https://jasp-stats.org/release-notes";
    description = "A complete statistical package for both Bayesian and Frequentist statistical methods";
    homepage = "https://github.com/jasp-stats/jasp-desktop";
    license = lib.licenses.agpl3;
    mainProgram = "JASP";
    maintainers = with lib.maintainers; [ tomasajt ];
    # JASP's cmake build steps are really different on Darwin
    # Perhaps the Darwin-specific things could be changed to be the same as Linux
    platforms = lib.platforms.linux;
  };
}