nixos/firmware: make compression configurable (#364924)
[NixPkgs.git] / pkgs / tools / misc / sharedown / default.nix
blob693c856b5461b0db5cc81b4a7c47f75ff2c6d77f
2   stdenvNoCC,
3   lib,
4   fetchFromGitHub,
5   ffmpeg,
6   yt-dlp,
7   libsecret,
8   python3,
9   pkg-config,
10   nodejs,
11   electron,
12   makeWrapper,
13   makeDesktopItem,
14   copyDesktopItems,
15   yarn2nix-moretea,
16   fetchYarnDeps,
17   chromium,
20 stdenvNoCC.mkDerivation rec {
21   pname = "Sharedown";
22   version = "5.3.1";
24   src = fetchFromGitHub {
25     owner = "kylon";
26     repo = "Sharedown";
27     rev = version;
28     sha256 = "sha256-llQt3m/qu7v5uQIfA1yxl2JZiFafk6sPgcvrIpQy/DI=";
29   };
31   nativeBuildInputs = [
32     copyDesktopItems
33     makeWrapper
34   ];
36   desktopItems = [
37     (makeDesktopItem {
38       name = "Sharedown";
39       exec = "Sharedown";
40       icon = "Sharedown";
41       comment = "An Application to save your Sharepoint videos for offline usage.";
42       desktopName = "Sharedown";
43       categories = [
44         "Network"
45         "Archiving"
46       ];
47     })
48   ];
50   dontBuild = true;
52   installPhase =
53     let
54       binPath = lib.makeBinPath ([
55         ffmpeg
56         yt-dlp
57       ]);
59       modules = yarn2nix-moretea.mkYarnModules rec {
60         name = "Sharedown-modules-${version}";
61         inherit pname version;
63         yarnFlags = [ "--production" ];
65         pkgConfig = {
66           keytar = {
67             nativeBuildInputs = [
68               python3
69               pkg-config
70             ];
71             buildInputs = [
72               libsecret
73             ];
74             postInstall = ''
75               yarn --offline run build
76               # Remove unnecessary store path references.
77               rm build/config.gypi
78             '';
79           };
80         };
82         # needed for node-gyp, copied from https://nixos.org/manual/nixpkgs/unstable/#javascript-yarn2nix-pitfalls
83         # permalink: https://github.com/NixOS/nixpkgs/blob/d176767c02cb2a048e766215078c3d231e666091/doc/languages-frameworks/javascript.section.md#pitfalls-javascript-yarn2nix-pitfalls
84         preBuild = ''
85           mkdir -p $HOME/.node-gyp/${nodejs.version}
86           echo 9 > $HOME/.node-gyp/${nodejs.version}/installVersion
87           ln -sfv ${nodejs}/include $HOME/.node-gyp/${nodejs.version}
88           export npm_config_nodedir=${nodejs}
89         '';
91         packageJSON = "${src}/package.json";
92         yarnLock = ./yarn.lock;
94         offlineCache = fetchYarnDeps {
95           inherit yarnLock;
96           hash = "sha256-NzWzkZbf5R1R72K7KVJbZUCzso1UZ0p3+lRYZE2M/dI=";
97         };
98       };
99     in
100     ''
101       runHook preInstall
103       mkdir -p "$out/bin" "$out/share/Sharedown" "$out/share/applications" "$out/share/icons/hicolor/512x512/apps"
105       # Electron app
106       cp -r *.js *.json sharedownlogo.png sharedown "${modules}/node_modules" "$out/share/Sharedown"
108       # Desktop Launcher
109       cp build/icon.png "$out/share/icons/hicolor/512x512/apps/Sharedown.png"
111       # Install electron wrapper script
112       makeWrapper "${electron}/bin/electron" "$out/bin/Sharedown" \
113         --add-flags "$out/share/Sharedown" \
114         --prefix PATH : "${binPath}" \
115         --set PUPPETEER_EXECUTABLE_PATH "${chromium}/bin/chromium"
117       runHook postInstall
118     '';
120   passthru.updateScript = ./update.sh;
122   meta = with lib; {
123     description = "Application to save your Sharepoint videos for offline usage";
124     homepage = "https://github.com/kylon/Sharedown";
125     license = licenses.gpl3Plus;
126     maintainers = with maintainers; [
127     ];
128     platforms = platforms.unix;
129     mainProgram = "Sharedown";
130   };