2021-10-01 09:20:50 +00:00
{ stdenvNoCC
, lib
, fetchFromGitHub
, ffmpeg
, yt-dlp
2022-02-10 20:34:41 +00:00
, libsecret
, python3
, pkg-config
, nodejs
2021-10-01 09:20:50 +00:00
, electron
, makeWrapper
, makeDesktopItem
, copyDesktopItems
, yarn2nix-moretea
, chromium
} :
2021-12-06 16:07:01 +00:00
stdenvNoCC . mkDerivation rec {
2021-10-01 09:20:50 +00:00
pname = " S h a r e d o w n " ;
2023-08-04 22:07:22 +00:00
version = " 5 . 3 . 1 " ;
2021-10-01 09:20:50 +00:00
src = fetchFromGitHub {
owner = " k y l o n " ;
repo = pname ;
rev = version ;
2023-08-04 22:07:22 +00:00
sha256 = " s h a 2 5 6 - l l Q t 3 m / q u 7 v 5 u Q I f A 1 y x l 2 J Z i F a f k 6 s P g c v r I p Q y / D I = " ;
2021-10-01 09:20:50 +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-03-05 16:20:37 +00:00
categories = [ " N e t w o r k " " A r c h i v i n g " ] ;
2021-10-01 09:20:50 +00:00
} )
] ;
dontBuild = true ;
2021-12-06 16:07:01 +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-08-12 12:06:08 +00:00
yarnFlags = [ " - - p r o d u c t i o n " ] ;
2021-12-06 16:07:01 +00:00
2022-02-10 20:34:41 +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-12-06 16:07:01 +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-10-01 09:20:50 +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 ;
} ;
}