2021-09-22 15:34:34 +00:00
{ stdenvNoCC
, lib
, fetchFromGitHub
, ffmpeg
, yt-dlp
2022-01-28 16:41:34 +00:00
, libsecret
, python3
, pkg-config
, nodejs
2021-09-22 15:34:34 +00:00
, electron
, makeWrapper
, makeDesktopItem
, copyDesktopItems
, yarn2nix-moretea
, chromium
} :
2021-10-29 00:15:40 +00:00
stdenvNoCC . mkDerivation rec {
2021-09-22 15:34:34 +00:00
pname = " S h a r e d o w n " ;
2023-02-05 23:04:56 +00:00
version = " 5 . 2 . 2 " ;
2021-09-22 15:34:34 +00:00
src = fetchFromGitHub {
owner = " k y l o n " ;
repo = pname ;
rev = version ;
2023-02-05 23:04:56 +00:00
sha256 = " s h a 2 5 6 - k d n t n z G p u 1 N U P 6 r r B a H 7 A S w E 7 X T 1 8 v H c g f 3 9 b p 5 A 4 d s = " ;
2021-09-22 15:34:34 +00:00
} ;
nativeBuildInputs = [
copyDesktopItems
makeWrapper
] ;
desktopItems = [
( makeDesktopItem {
name = " S h a r e d o w n " ;
exec = " S h a r e d o w n " ;
icon = " S h a r e d o w n " ;
comment = " A n A p p l i c a t i o n t o s a v e y o u r S h a r e p o i n t v i d e o s f o r o f f l i n e u s a g e . " ;
desktopName = " S h a r e d o w n " ;
2022-02-22 14:56:15 +00:00
categories = [ " N e t w o r k " " A r c h i v i n g " ] ;
2021-09-22 15:34:34 +00:00
} )
] ;
dontBuild = true ;
2021-10-29 00:15:40 +00:00
installPhase =
let
binPath = lib . makeBinPath ( [
ffmpeg
yt-dlp
] ) ;
modules = yarn2nix-moretea . mkYarnModules {
name = " ${ pname } - m o d u l e s - ${ version } " ;
inherit pname version ;
2022-07-24 12:54:33 +00:00
yarnFlags = [ " - - p r o d u c t i o n " ] ;
2021-10-29 00:15:40 +00:00
2022-01-28 16:41:34 +00:00
pkgConfig = {
keytar = {
nativeBuildInputs = [
python3
pkg-config
] ;
buildInputs = [
libsecret
] ;
postInstall = ''
yarn - - offline run build
# Remove unnecessary store path references.
rm build/config.gypi
'' ;
} ;
} ;
preBuild = ''
# Set up headers for node-gyp, which is needed to build keytar.
mkdir - p " $ H O M E / . c a c h e / n o d e - g y p / ${ nodejs . version } "
# 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>.
echo 9 > " $ H O M E / . c a c h e / n o d e - g y p / ${ nodejs . version } / i n s t a l l V e r s i o n "
# Link node headers so that node-gyp does not try to download them.
ln - sfv " ${ nodejs } / i n c l u d e " " $ H O M E / . c a c h e / n o d e - g y p / ${ nodejs . version } "
'' ;
2021-10-29 00:15:40 +00:00
packageJSON = " ${ src } / p a c k a g e . j s o n " ;
yarnLock = ./yarn.lock ;
yarnNix = ./yarndeps.nix ;
} ;
in
''
runHook preInstall
mkdir - p " $ o u t / b i n " " $ o u t / s h a r e / S h a r e d o w n " " $ o u t / s h a r e / a p p l i c a t i o n s " " $ o u t / s h a r e / i c o n s / h i c o l o r / 5 1 2 x 5 1 2 / a p p s "
# Electron app
cp - r * . js * . json sharedownlogo . png sharedown " ${ modules } / n o d e _ m o d u l e s " " $ o u t / s h a r e / S h a r e d o w n "
# Desktop Launcher
cp build/icon.png " $ o u t / s h a r e / i c o n s / h i c o l o r / 5 1 2 x 5 1 2 / a p p s / S h a r e d o w n . p n g "
# Install electron wrapper script
makeWrapper " ${ electron } / b i n / e l e c t r o n " " $ o u t / b i n / S h a r e d o w n " \
- - add-flags " $ o u t / s h a r e / S h a r e d o w n " \
- - prefix PATH : " ${ binPath } " \
- - set PUPPETEER_EXECUTABLE_PATH " ${ chromium } / b i n / c h r o m i u m "
runHook postInstall
'' ;
2021-09-22 15:34:34 +00:00
passthru . updateScript = ./update.sh ;
meta = with lib ; {
description = " A p p l i c a t i o n t o s a v e y o u r S h a r e p o i n t v i d e o s f o r o f f l i n e u s a g e " ;
homepage = " h t t p s : / / g i t h u b . c o m / k y l o n / S h a r e d o w n " ;
license = licenses . gpl3Plus ;
maintainers = with maintainers ; [
] ;
platforms = platforms . unix ;
} ;
}