biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / development / tools / electron-fiddle / default.nix
blob16d96297c544f661333af743ed02088400bf4a4b
1 { buildFHSEnv
2 , electron_24
3 , fetchFromGitHub
4 , fetchYarnDeps
5 , fetchurl
6 , fixup-yarn-lock
7 , git
8 , lib
9 , makeDesktopItem
10 , nodejs_18
11 , stdenvNoCC
12 , util-linux
13 , zip
16 let
17   pname = "electron-fiddle";
18   version = "0.32.6";
19   electron = electron_24;
20   nodejs = nodejs_18;
22   src = fetchFromGitHub {
23     owner = "electron";
24     repo = "fiddle";
25     rev = "v${version}";
26     hash = "sha256-Iuss2xwts1aWy2rKYG7J2EvFdH8Bbedn/uZG2bi9UHw=";
27   };
29   # As of https://github.com/electron/fiddle/pull/1316 this is fetched
30   # from the network and has no stable hash.  Grab an old version from
31   # the repository.
32   releasesJson = fetchurl {
33     url = "https://raw.githubusercontent.com/electron/fiddle/v0.32.4~18/static/releases.json";
34     hash = "sha256-1sxd3eJ6/WjXS6XQbrgKUTNUmrhuc1dAvy+VAivGErg=";
35   };
37   inherit (nodejs.pkgs) yarn;
38   offlineCache = fetchYarnDeps {
39     yarnLock = "${src}/yarn.lock";
40     hash = "sha256-dwhwUWwv6RYKEMdhRBvKVXvM8n1r+Qo0D3/uFsWIOpw=";
41   };
43   electronDummyMirror = "https://electron.invalid/";
44   electronDummyDir = "nix";
45   electronDummyFilename =
46     builtins.baseNameOf (builtins.head (electron.src.urls));
47   electronDummyHash =
48     builtins.hashString "sha256" "${electronDummyMirror}${electronDummyDir}";
50   unwrapped = stdenvNoCC.mkDerivation {
51     pname = "${pname}-unwrapped";
52     inherit version src;
54     nativeBuildInputs = [ fixup-yarn-lock git nodejs util-linux yarn zip ];
56     configurePhase = ''
57       export HOME=$TMPDIR
58       fixup-yarn-lock yarn.lock
59       yarn config --offline set yarn-offline-mirror ${offlineCache}
60       yarn install --offline --frozen-lockfile --ignore-scripts --no-progress --non-interactive
61       patchShebangs node_modules
63       mkdir -p ~/.cache/electron/${electronDummyHash}
64       cp -ra '${electron}/libexec/electron' "$TMPDIR/electron"
65       chmod -R u+w "$TMPDIR/electron"
66       (cd "$TMPDIR/electron" && zip -0Xr ~/.cache/electron/${electronDummyHash}/${electronDummyFilename} .)
68       ln -s ${releasesJson} static/releases.json
69     '';
71     buildPhase = ''
72       ELECTRON_CUSTOM_VERSION='${electron.version}' \
73         ELECTRON_MIRROR='${electronDummyMirror}' \
74         ELECTRON_CUSTOM_DIR='${electronDummyDir}' \
75         ELECTRON_CUSTOM_FILENAME='${electronDummyFilename}' \
76         yarn --offline run package
77     '';
79     installPhase = ''
80       mkdir -p "$out/lib/electron-fiddle/resources"
81       cp "out/Electron Fiddle-"*/resources/app.asar "$out/lib/electron-fiddle/resources/"
82       mkdir -p "$out/share/icons/hicolor/scalable/apps"
83       cp assets/icons/fiddle.svg "$out/share/icons/hicolor/scalable/apps/electron-fiddle.svg"
84     '';
85   };
87   desktopItem = makeDesktopItem {
88     name = "electron-fiddle";
89     desktopName = "Electron Fiddle";
90     comment = "The easiest way to get started with Electron";
91     genericName = "Electron Fiddle";
92     exec = "electron-fiddle %U";
93     icon = "electron-fiddle";
94     startupNotify = true;
95     categories = [ "GNOME" "GTK" "Utility" ];
96     mimeTypes = [ "x-scheme-handler/electron-fiddle" ];
97   };
100 buildFHSEnv {
101   name = "electron-fiddle";
102   runScript = "${electron}/bin/electron ${unwrapped}/lib/electron-fiddle/resources/app.asar";
104   extraInstallCommands = ''
105     mkdir -p "$out/share/icons/hicolor/scalable/apps"
106     ln -s "${unwrapped}/share/icons/hicolor/scalable/apps/electron-fiddle.svg" "$out/share/icons/hicolor/scalable/apps/"
107     mkdir -p "$out/share/applications"
108     cp "${desktopItem}/share/applications"/*.desktop "$out/share/applications/"
109   '';
111   targetPkgs = pkgs:
112     with pkgs;
113     map lib.getLib [
114       # for electron-fiddle itself
115       udev
117       # for running Electron 22.0.0 inside
118       alsa-lib
119       atk
120       cairo
121       cups
122       dbus
123       expat
124       glib
125       gtk3
126       libdrm
127       libnotify
128       libxkbcommon
129       mesa
130       nspr
131       nss
132       pango
133       xorg.libX11
134       xorg.libXcomposite
135       xorg.libXdamage
136       xorg.libXext
137       xorg.libXfixes
138       xorg.libXrandr
139       xorg.libxcb
141       # for running Electron before 18.3.5/19.0.5/20.0.0 inside
142       gdk-pixbuf
144       # for running Electron before 16.0.0 inside
145       xorg.libxshmfence
147       # for running Electron before 11.0.0 inside
148       xorg.libXcursor
149       xorg.libXi
150       xorg.libXrender
151       xorg.libXtst
153       # for running Electron before 10.0.0 inside
154       xorg.libXScrnSaver
156       # for running Electron before 8.0.0 inside
157       libuuid
159       # for running Electron before 4.0.0 inside
160       fontconfig
162       # for running Electron before 3.0.0 inside
163       gnome2.GConf
165       # Electron 2.0.8 is the earliest working version, due to
166       # https://github.com/electron/electron/issues/13972
167     ];
169   meta = with lib; {
170     description = "The easiest way to get started with Electron";
171     homepage = "https://www.electronjs.org/fiddle";
172     license = licenses.mit;
173     maintainers = with maintainers; [ andersk ];
174     platforms = electron.meta.platforms;
175   };