blob: 6ebff8ae7473cc6f9792749690e7a00d91d22f48 [file] [log] [blame]
Skyler Turner0d7935c2022-03-29 20:10:00 +01001{ pkgs, lib, stdenv, unzip, fetchurl, makeDesktopItem, buildFHSUserEnv
Skyler Turnerbc7f6dc2022-03-29 18:40:01 +01002# Specify any font packages to include
3# e.g. figma.override { fonts = [ noto-fonts fira-code ]; }
4, fonts ? [ ]
5}:
6
7let
Skyler Grey60b078a2022-05-31 08:50:16 +01008 version = "0.10.0";
Skyler Turnerbc7f6dc2022-03-29 18:40:01 +01009 # Figma executable.
10 # Currently won't run outside of FHS even with autopatching - needs help.
11 figma-exec = stdenv.mkDerivation rec {
12 inherit version;
13 pname = "figma-exec";
14 src = fetchurl {
15 url = "https://github.com/Figma-Linux/figma-linux/releases/download/v${version}/figma-linux_${version}_linux_amd64.zip";
Skyler Greya220d572022-05-31 08:55:59 +010016 sha256 = "sha256-1jdaa/oZu5io/sHHkNzdrCgWWfqW0AMqUGx6amJJpyU=";
Skyler Turnerbc7f6dc2022-03-29 18:40:01 +010017 };
18 buildInputs = [ unzip ];
19 unpackPhase = ''
20 runHook preUnpack
21 mkdir output
22 unzip $src -d output
23 runHook postUnpack
24 '';
25 installPhase = ''
26 APPDIR=$out/etc/figma-linux
27 # Copy application to etc
28 mkdir -p $out/etc/figma-linux
29 cp -r output/. $APPDIR
30
31 # Add icons
32 for size in 24 36 48 64 72 96 128 192 256 384 512; do
33 mkdir -p "$out/share/icons/hicolor/''${size}x''${size}/apps"
34 cp -rf "$APPDIR/icons/''${size}x''${size}.png" "$out/share/icons/hicolor/''${size}x''${size}/apps/figma-linux.png"
35 done
36 mkdir -p "$out/share/icons/hicolor/scalable/apps"
37 cp -rf "$APPDIR/icons/scalable.svg" "$out/share/icons/hicolor/scalable/apps/figma-linux.svg"
38
39 # Copy fonts
40 mkdir -p $out/share/fonts
41 ${lib.concatMapStringsSep "\n"
42 (f: "cp -r ${f}/share/fonts/. $out/share/fonts/") fonts}
43
44 # Link binary
45 mkdir -p $out/bin
46 ln -s $out/etc/figma-linux/figma-linux $out/bin/figma
47
48 # Link desktop item
49 mkdir -p $out/share/applications
50 ln -s ${desktopItem}/share/applications/* $out/share/applications
51 '';
52 desktopItem = makeDesktopItem {
53 name = "Figma";
54 exec = "figma";
55 icon = "figma-linux";
56 desktopName = "Figma";
57 genericName = "Vector Graphics Designer";
58 comment = "Unofficial desktop application for linux";
59 type = "Application";
Skyler Grey60b078a2022-05-31 08:50:16 +010060 categories = [ "Graphics" ];
61 mimeTypes = [ "application/figma" "x-scheme-handler/figma" ];
62 extraConfig = { StartupWMClass = "figma-linux"; };
Skyler Turnerbc7f6dc2022-03-29 18:40:01 +010063 };
64 };
65 figma-fhs = buildFHSUserEnv {
66 name = "figma-fhs";
Skyler Turner0d7935c2022-03-29 20:10:00 +010067 targetPkgs = pkgs: with pkgs; [
Skyler Turnerbc7f6dc2022-03-29 18:40:01 +010068 figma-exec
69 alsaLib
Skyler Grey60b078a2022-05-31 08:50:16 +010070 at-spi2-atk
71 at-spi2-core
Skyler Turnerbc7f6dc2022-03-29 18:40:01 +010072 atk
73 avahi
74 brotli
75 cairo
76 cups
77 dbus
78 expat
79 freetype
80 pango
81 gcc
82 glib
83 glibc
Skyler Grey60b078a2022-05-31 08:50:16 +010084 gdk-pixbuf
Skyler Turnerbc7f6dc2022-03-29 18:40:01 +010085 gtk3
86 icu
87 libxkbcommon
88 mesa
89 ffmpeg
90 libdrm
91 libGL
Skyler Turnerfa37d1c2022-03-29 20:15:36 +010092 nss
Skyler Turnerbc7f6dc2022-03-29 18:40:01 +010093 nspr
94 udev
95 xorg.libXdamage
96 xorg.libXext
97 xorg.libX11
98 xorg.libXau
99 xorg.libxcb
100 xorg.libXcomposite
101 xorg.libXdmcp
102 xorg.libXfixes
103 xorg.libXrender
104 xorg.libXrandr
105 xorg.libxshmfence
106 wayland
107 ];
108 runScript = "figma";
109 };
110
111in stdenv.mkDerivation {
112 pname = "figma";
113 inherit version;
114 src = builtins.path { path = ./.; };
115 nativeBuildInputs = [ figma-fhs ];
116 installPhase = ''
117 # Add binary link
118 mkdir -p $out/bin
119 cp -r ${figma-fhs}/bin/figma-fhs $out/bin/figma
120
121 # Link icons + desktop items
122 mkdir -p $out/share
123 cp -r ${figma-exec}/share/. $out/share
124 '';
125 meta = with lib; {
126 description = "unofficial Electron-based Figma desktop app for Linux";
127 homepage = "https://github.com/Figma-Linux/figma-linux";
128 # While the container application is GPL-2.0,
129 # Figma itself (running in the application) is nonFree.
130 license = licenses.unfree;
131 };
132}