Skyler Turner | 29dc28e | 2022-03-29 20:09:07 +0100 | [diff] [blame^] | 1 | { pkgs, lib, stdenv, unzip, fetchurl, makeDesktopItem, buildFHSUserEnv, alsaLib |
Skyler Turner | bc7f6dc | 2022-03-29 18:40:01 +0100 | [diff] [blame] | 2 | # Specify any font packages to include |
| 3 | # e.g. figma.override { fonts = [ noto-fonts fira-code ]; } |
| 4 | , fonts ? [ ] |
| 5 | }: |
| 6 | |
| 7 | let |
| 8 | version = "0.8.1"; |
| 9 | # 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"; |
| 16 | sha256 = "sha256-LqcjFLQeEQx/3HFy0mPoIynFy704omYVxv42IsY7s8k="; |
| 17 | }; |
| 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"; |
| 60 | categories = "Graphics;"; |
| 61 | mimeType = "application/figma;x-scheme-handler/figma;"; |
| 62 | extraDesktopEntries = { StartupWMClass = "figma-linux"; }; |
| 63 | }; |
| 64 | }; |
| 65 | figma-fhs = buildFHSUserEnv { |
| 66 | name = "figma-fhs"; |
| 67 | targetPkgs = pkgs: [ |
| 68 | figma-exec |
| 69 | alsaLib |
| 70 | at_spi2_atk |
| 71 | at_spi2_core |
| 72 | atk |
| 73 | avahi |
| 74 | brotli |
| 75 | cairo |
| 76 | cups |
| 77 | dbus |
| 78 | expat |
| 79 | freetype |
| 80 | pango |
| 81 | gcc |
| 82 | glib |
| 83 | glibc |
| 84 | gdk_pixbuf |
| 85 | gtk3 |
| 86 | icu |
| 87 | libxkbcommon |
| 88 | mesa |
| 89 | ffmpeg |
| 90 | libdrm |
| 91 | libGL |
| 92 | nss_3_53 |
| 93 | 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 | |
| 111 | in 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 | } |