nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at litex 123 lines 3.3 kB view raw
1{ stdenvNoCC 2, lib 3, fetchFromGitHub 4, ffmpeg 5, yt-dlp 6, libsecret 7, python3 8, pkg-config 9, nodejs 10, electron 11, makeWrapper 12, makeDesktopItem 13, copyDesktopItems 14, yarn2nix-moretea 15, chromium 16}: 17 18stdenvNoCC.mkDerivation rec { 19 pname = "Sharedown"; 20 version = "5.2.2"; 21 22 src = fetchFromGitHub { 23 owner = "kylon"; 24 repo = pname; 25 rev = version; 26 sha256 = "sha256-kdntnzGpu1NUP6rrBaH7ASwE7XT18vHcgf39bp5A4ds="; 27 }; 28 29 nativeBuildInputs = [ 30 copyDesktopItems 31 makeWrapper 32 ]; 33 34 desktopItems = [ 35 (makeDesktopItem { 36 name = "Sharedown"; 37 exec = "Sharedown"; 38 icon = "Sharedown"; 39 comment = "An Application to save your Sharepoint videos for offline usage."; 40 desktopName = "Sharedown"; 41 categories = [ "Network" "Archiving" ]; 42 }) 43 ]; 44 45 dontBuild = true; 46 47 installPhase = 48 let 49 binPath = lib.makeBinPath ([ 50 ffmpeg 51 yt-dlp 52 ]); 53 54 modules = yarn2nix-moretea.mkYarnModules { 55 name = "${pname}-modules-${version}"; 56 inherit pname version; 57 58 yarnFlags = [ "--production" ]; 59 60 pkgConfig = { 61 keytar = { 62 nativeBuildInputs = [ 63 python3 64 pkg-config 65 ]; 66 buildInputs = [ 67 libsecret 68 ]; 69 postInstall = '' 70 yarn --offline run build 71 # Remove unnecessary store path references. 72 rm build/config.gypi 73 ''; 74 }; 75 }; 76 77 preBuild = '' 78 # Set up headers for node-gyp, which is needed to build keytar. 79 mkdir -p "$HOME/.cache/node-gyp/${nodejs.version}" 80 81 # Set up version which node-gyp checks in <https://github.com/nodejs/node-gyp/blob/4937722cf597ccd1953628f3d5e2ab5204280051/lib/install.js#L87-L96> against the version in <https://github.com/nodejs/node-gyp/blob/4937722cf597ccd1953628f3d5e2ab5204280051/package.json#L15>. 82 echo 9 > "$HOME/.cache/node-gyp/${nodejs.version}/installVersion" 83 84 # Link node headers so that node-gyp does not try to download them. 85 ln -sfv "${nodejs}/include" "$HOME/.cache/node-gyp/${nodejs.version}" 86 ''; 87 88 packageJSON = "${src}/package.json"; 89 yarnLock = ./yarn.lock; 90 yarnNix = ./yarndeps.nix; 91 }; 92 in 93 '' 94 runHook preInstall 95 96 mkdir -p "$out/bin" "$out/share/Sharedown" "$out/share/applications" "$out/share/icons/hicolor/512x512/apps" 97 98 # Electron app 99 cp -r *.js *.json sharedownlogo.png sharedown "${modules}/node_modules" "$out/share/Sharedown" 100 101 # Desktop Launcher 102 cp build/icon.png "$out/share/icons/hicolor/512x512/apps/Sharedown.png" 103 104 # Install electron wrapper script 105 makeWrapper "${electron}/bin/electron" "$out/bin/Sharedown" \ 106 --add-flags "$out/share/Sharedown" \ 107 --prefix PATH : "${binPath}" \ 108 --set PUPPETEER_EXECUTABLE_PATH "${chromium}/bin/chromium" 109 110 runHook postInstall 111 ''; 112 113 passthru.updateScript = ./update.sh; 114 115 meta = with lib; { 116 description = "Application to save your Sharepoint videos for offline usage"; 117 homepage = "https://github.com/kylon/Sharedown"; 118 license = licenses.gpl3Plus; 119 maintainers = with maintainers; [ 120 ]; 121 platforms = platforms.unix; 122 }; 123}