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