nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenvNoCC,
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,
18}:
19
20stdenvNoCC.mkDerivation rec {
21 pname = "Sharedown";
22 version = "5.3.6";
23
24 src = fetchFromGitHub {
25 owner = "kylon";
26 repo = "Sharedown";
27 tag = version;
28 hash = "sha256-5t/71T/eBg4vkDZTj7mtCkXhS+AuiVhBmx0Zzrry5Lg=";
29 };
30
31 nativeBuildInputs = [
32 copyDesktopItems
33 makeWrapper
34 ];
35
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 ];
49
50 dontBuild = true;
51
52 installPhase =
53 let
54 binPath = lib.makeBinPath ([
55 ffmpeg
56 yt-dlp
57 ]);
58
59 modules = yarn2nix-moretea.mkYarnModules rec {
60 name = "Sharedown-modules-${version}";
61 inherit pname version;
62
63 yarnFlags = [ "--production" ];
64
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 };
81
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 '';
90
91 postBuild = ''
92 rm $out/node_modules/sharedown
93 '';
94
95 packageJSON = "${src}/package.json";
96 yarnLock = ./yarn.lock;
97
98 offlineCache = fetchYarnDeps {
99 inherit yarnLock;
100 hash = "sha256-9Mdn18jJTXyAVQMGl9ImIEbzlkK6walPrgkGzupLPFQ=";
101 };
102 };
103 in
104 ''
105 runHook preInstall
106
107 mkdir -p "$out/bin" "$out/share/Sharedown" "$out/share/applications" "$out/share/icons/hicolor/512x512/apps"
108
109 # Electron app
110 cp -r *.js *.json sharedownlogo.png sharedown "${modules}/node_modules" "$out/share/Sharedown"
111
112 # Desktop Launcher
113 cp build/icon.png "$out/share/icons/hicolor/512x512/apps/Sharedown.png"
114
115 # Install electron wrapper script
116 makeWrapper "${electron}/bin/electron" "$out/bin/Sharedown" \
117 --add-flags "$out/share/Sharedown" \
118 --prefix PATH : "${binPath}" \
119 --set PUPPETEER_EXECUTABLE_PATH "${chromium}/bin/chromium"
120
121 runHook postInstall
122 '';
123
124 passthru.updateScript = ./update.sh;
125
126 meta = {
127 description = "Application to save your Sharepoint videos for offline usage";
128 homepage = "https://github.com/kylon/Sharedown";
129 license = lib.licenses.gpl3Plus;
130 maintainers = with lib.maintainers; [ ];
131 platforms = lib.platforms.unix;
132 mainProgram = "Sharedown";
133 };
134}