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