about summary refs log tree commit diff
path: root/pkgs/applications/graphics/lorien/default.nix
blob: e3e8daf876622e2b55a1a0d37d97190b4da456a9 (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
{ lib
, stdenv
, fetchFromGitHub

, copyDesktopItems
, makeDesktopItem

, godot-export-templates
, godot-headless

, alsa-lib
, libGL
, libGLU
, libX11
, libXcursor
, libXext
, libXfixes
, libXi
, libXinerama
, libXrandr
, libXrender
, zlib
, udev # for libudev
}:

let
  preset =
    if stdenv.isLinux then "Linux/X11"
    else if stdenv.isDarwin then "Mac OSX"
    else throw "unsupported platform";
in
stdenv.mkDerivation rec {
  pname = "lorien";
  version = "0.5.0";

  src = fetchFromGitHub {
    owner = "mbrlabs";
    repo = "Lorien";
    rev = "v${version}";
    sha256 = "sha256-x81Obana2BEGrYSoJHDdCkL6UaULfQGQ94tlrH5+kdY=";
  };

  nativeBuildInputs = [
    copyDesktopItems
    godot-headless
  ];

  buildInputs = [
    alsa-lib
    libGL
    libGLU
    libX11
    libXcursor
    libXext
    libXfixes
    libXi
    libXinerama
    libXrandr
    libXrender
    zlib
    udev
  ];

  desktopItems = [
    (makeDesktopItem {
      name = "lorien";
      exec = "lorien";
      icon = "lorien";
      desktopName = "Lorien";
      genericName = "Whiteboard";
      comment = meta.description;
      categories = [ "Graphics" "Office" ];
      keywords = [ "whiteboard" ];
    })
  ];

  buildPhase = ''
    runHook preBuild

    # Cannot create file '/homeless-shelter/.config/godot/projects/...'
    export HOME=$TMPDIR

    # Link the export-templates to the expected location. The --export commands
    # expects the template-file at .../templates/{godot-version}.stable/linux_x11_64_release
    mkdir -p $HOME/.local/share/godot
    ln -s ${godot-export-templates}/share/godot/templates $HOME/.local/share/godot

    mkdir -p $out/share/lorien

    godot-headless --path lorien --export "${preset}" $out/share/lorien/lorien

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin
    ln -s $out/share/lorien/lorien $out/bin

    # Patch binaries.
    interpreter=$(cat $NIX_CC/nix-support/dynamic-linker)
    patchelf \
      --set-interpreter $interpreter \
      --set-rpath ${lib.makeLibraryPath buildInputs} \
      $out/share/lorien/lorien

    install -Dm644 images/lorien.png $out/share/pixmaps/lorien.png

    runHook postInstall
  '';

  meta = with lib; {
    homepage = "https://github.com/mbrlabs/Lorien";
    description = "An infinite canvas drawing/note-taking app";
    longDescription = ''
      An infinite canvas drawing/note-taking app that is focused on performance,
      small savefiles and simplicity
    '';
    license = licenses.mit;
    platforms   = platforms.unix;
    maintainers = with maintainers; [ hqurve ];
  };
}