2021-09-22 17:34:34 +02:00
{ stdenvNoCC
, lib
, fetchFromGitHub
, ffmpeg
, yt-dlp
2022-01-28 17:41:34 +01:00
, libsecret
, python3
, pkg-config
, nodejs
2021-09-22 17:34:34 +02:00
, electron
, makeWrapper
, makeDesktopItem
, copyDesktopItems
, yarn2nix-moretea
, chromium
} :
2021-10-29 02:15:40 +02:00
stdenvNoCC . mkDerivation rec {
2021-09-22 17:34:34 +02:00
pname = " S h a r e d o w n " ;
2022-09-12 04:53:44 +02:00
version = " 5 . 0 . 2 " ;
2021-09-22 17:34:34 +02:00
src = fetchFromGitHub {
owner = " k y l o n " ;
repo = pname ;
rev = version ;
2022-09-12 04:53:44 +02:00
sha256 = " s h a 2 5 6 - N 5 j n j i D 3 R + u T R g H H o c V V x Y Q 7 G z U T z 0 f Z A Q G I X z c V T t A = " ;
2021-09-22 17:34:34 +02: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 15:56:15 +01:00
categories = [ " N e t w o r k " " A r c h i v i n g " ] ;
2021-09-22 17:34:34 +02:00
} )
] ;
dontBuild = true ;
2021-10-29 02:15:40 +02: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 14:54:33 +02:00
yarnFlags = [ " - - p r o d u c t i o n " ] ;
2021-10-29 02:15:40 +02:00
2022-01-28 17:41:34 +01: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 02:15:40 +02: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 17:34:34 +02: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 ;
} ;
}