1{ stdenvNoCC
2, lib
3, fetchFromGitHub
4, ffmpeg
5, yt-dlp
6, libsecret
7, python3
8, pkg-config
9, nodePackages
10, electron
11, makeWrapper
12, makeDesktopItem
13, copyDesktopItems
14, yarn2nix-moretea
15, fetchYarnDeps
16, chromium
17}:
18
19stdenvNoCC.mkDerivation rec {
20 pname = "Sharedown";
21 version = "5.3.1";
22
23 src = fetchFromGitHub {
24 owner = "kylon";
25 repo = pname;
26 rev = version;
27 sha256 = "sha256-llQt3m/qu7v5uQIfA1yxl2JZiFafk6sPgcvrIpQy/DI=";
28 };
29
30 nativeBuildInputs = [
31 copyDesktopItems
32 makeWrapper
33 ];
34
35 desktopItems = [
36 (makeDesktopItem {
37 name = "Sharedown";
38 exec = "Sharedown";
39 icon = "Sharedown";
40 comment = "An Application to save your Sharepoint videos for offline usage.";
41 desktopName = "Sharedown";
42 categories = [ "Network" "Archiving" ];
43 })
44 ];
45
46 dontBuild = true;
47
48 installPhase =
49 let
50 binPath = lib.makeBinPath ([
51 ffmpeg
52 yt-dlp
53 ]);
54
55 modules = yarn2nix-moretea.mkYarnModules rec {
56 name = "${pname}-modules-${version}";
57 inherit pname version;
58
59 yarnFlags = [ "--production" ];
60
61 pkgConfig = {
62 keytar = {
63 nativeBuildInputs = [
64 python3
65 pkg-config
66 nodePackages.node-gyp
67 ];
68 buildInputs = [
69 libsecret
70 ];
71 postInstall = ''
72 yarn --offline run build
73 # Remove unnecessary store path references.
74 rm build/config.gypi
75 '';
76 };
77 };
78
79 packageJSON = "${src}/package.json";
80 yarnLock = ./yarn.lock;
81
82 offlineCache = fetchYarnDeps {
83 inherit yarnLock;
84 hash = "sha256-NzWzkZbf5R1R72K7KVJbZUCzso1UZ0p3+lRYZE2M/dI=";
85 };
86 };
87 in
88 ''
89 runHook preInstall
90
91 mkdir -p "$out/bin" "$out/share/Sharedown" "$out/share/applications" "$out/share/icons/hicolor/512x512/apps"
92
93 # Electron app
94 cp -r *.js *.json sharedownlogo.png sharedown "${modules}/node_modules" "$out/share/Sharedown"
95
96 # Desktop Launcher
97 cp build/icon.png "$out/share/icons/hicolor/512x512/apps/Sharedown.png"
98
99 # Install electron wrapper script
100 makeWrapper "${electron}/bin/electron" "$out/bin/Sharedown" \
101 --add-flags "$out/share/Sharedown" \
102 --prefix PATH : "${binPath}" \
103 --set PUPPETEER_EXECUTABLE_PATH "${chromium}/bin/chromium"
104
105 runHook postInstall
106 '';
107
108 passthru.updateScript = ./update.sh;
109
110 meta = with lib; {
111 description = "Application to save your Sharepoint videos for offline usage";
112 homepage = "https://github.com/kylon/Sharedown";
113 license = licenses.gpl3Plus;
114 maintainers = with maintainers; [
115 ];
116 platforms = platforms.unix;
117 };
118}