about summary refs log tree commit diff
path: root/pkgs/development/tools/glamoroustoolkit/default.nix
blob: 3a32bfdaddaa2343659600ded651045b9bbb0730 (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
{ lib
, stdenv
, fetchzip
, wrapGAppsHook
, cairo
, dbus
, fontconfig
, freetype
, glib
, gtk3
, libX11
, libXcursor
, libXext
, libXi
, libXrandr
, libXrender
, libgit2
, libglvnd
, libuuid
, libxcb
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "glamoroustoolkit";
  version = "1.0.11";

  src = fetchzip {
    url = "https://github.com/feenkcom/gtoolkit-vm/releases/download/v${finalAttrs.version}/GlamorousToolkit-x86_64-unknown-linux-gnu.zip";
    stripRoot = false;
    hash = "sha256-GQeYR232zoHLIt1AzznD7rp6u4zMiAdj1+0OfXfT6AQ=";
  };

  nativeBuildInputs = [ wrapGAppsHook ];

  sourceRoot = ".";

  dontConfigure = true;
  dontBuild = true;
  dontPatchELF = true;

  installPhase = ''
    runHook preInstall

    install -d $out/bin $out/lib
    cp -r $src/bin $src/lib $out/
    cp ${./GlamorousToolkit-GetImage} $out/bin/GlamorousToolkit-GetImage

    runHook postInstall
  '';

preFixup = let
    libPath = lib.makeLibraryPath [
      cairo
      dbus
      fontconfig
      freetype
      glib
      gtk3
      libX11
      libXcursor
      libXext
      libXi
      libXrandr
      libXrender
      libglvnd
      libuuid
      libxcb
      stdenv.cc.cc.lib
    ];
  in ''
    chmod +x $out/lib/*.so
    patchelf \
      --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
      --set-rpath "${libPath}:$out/lib" \
      $out/bin/GlamorousToolkit $out/bin/GlamorousToolkit-cli
    patchelf --shrink-rpath \
      $out/bin/GlamorousToolkit $out/bin/GlamorousToolkit-cli
    patchelf \
      --set-rpath "${libPath}:$out/lib" \
      $out/lib/*.so
    patchelf --shrink-rpath $out/lib/*.so
    #
    # shrink-rpath gets it wrong for the following libraries,
    # restore the full rpath.
    #
    patchelf \
      --set-rpath "${libPath}:$out/lib" \
      $out/lib/libPharoVMCore.so \
      $out/lib/libWinit.so \
      $out/lib/libPixels.so
    patchelf --set-rpath $out/lib $out/lib/libssl.so

    ln -s $out/lib/libcrypto.so $out/lib/libcrypto.so.1.1
    ln -s $out/lib/libcairo.so $out/lib/libcairo.so.2
    rm $out/lib/libgit2.so
    ln -s "${libgit2}/lib/libgit2.so" $out/lib/libgit2.so.1.1
  '';

  meta = {
    homepage = "https://gtoolkit.com";
    description = "The GlamorousToolkit Development Environment";
    license = lib.licenses.mit;
    maintainers = [ lib.maintainers.akgrant43 ];
    platforms = [ "x86_64-linux" ];
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
  };
})