2024-09-19 14:19:46 +00:00
{
lib ,
stdenv ,
python ,
buildPythonPackage ,
callPackage ,
fetchurl ,
autoPatchelfHook ,
bash ,
dejavu_fonts ,
expat ,
fontconfig ,
lato ,
libGL ,
makeWrapper ,
nspr ,
nss ,
sbclPackages ,
sqlite ,
} :
buildPythonPackage rec {
pname = " k a l e i d o " ;
version = " 0 . 2 . 1 " ;
format = " w h e e l " ;
src =
{
# This library is so cursed that I have to use fetchurl instead of fetchPypi. I am not happy.
x86_64-linux = fetchurl {
url = " h t t p s : / / f i l e s . p y t h o n h o s t e d . o r g / p a c k a g e s / p y 2 . p y 3 / k / k a l e i d o / k a l e i d o - ${ version } - p y 2 . p y 3 - n o n e - m a n y l i n u x 1 _ x 8 6 _ 6 4 . w h l " ;
hash = " s h a 2 5 6 - q i H P G / H H j 4 + l C p 9 9 R e E A P D h 7 0 9 b + C n Z 8 + 7 8 0 S 5 W 9 w 6 g = " ;
} ;
aarch64-linux = fetchurl {
url = " h t t p s : / / f i l e s . p y t h o n h o s t e d . o r g / p a c k a g e s / p y 2 . p y 3 / k / k a l e i d o / k a l e i d o - ${ version } - p y 2 . p y 3 - n o n e - m a n y l i n u x 2 0 1 4 _ a a r c h 6 4 . w h l " ;
hash = " s h a 2 5 6 - h F g Z h E y A g s l G n Z w X 5 C Y h + / h c K y N + + K h u y K h S f 5 i 2 U S o = " ;
} ;
x86_64-darwin = fetchurl {
url = " h t t p s : / / f i l e s . p y t h o n h o s t e d . o r g / p a c k a g e s / p y 2 . p y 3 / k / k a l e i d o / k a l e i d o - ${ version } - p y 2 . p y 3 - n o n e - m a c o s x _ 1 0 _ 1 1 _ x 8 6 _ 6 4 . w h l " ;
hash = " s h a 2 5 6 - y m 9 z 5 / 8 A q u v y h D 9 z 8 d O 6 z e G T D v U E E J P + d r g 6 F X h Q S a c = " ;
} ;
aarch64-darwin = fetchurl {
url = " h t t p s : / / f i l e s . p y t h o n h o s t e d . o r g / p a c k a g e s / p y 2 . p y 3 / k / k a l e i d o / k a l e i d o - ${ version } - p y 2 . p y 3 - n o n e - m a c o s x _ 1 1 _ 0 _ a r m 6 4 . w h l " ;
hash = " s h a 2 5 6 - u 5 p d H 3 E D V 9 X U M u 4 k D v Z l i m 0 S T D 5 h C T W B e 0 t C 2 p x 4 f A U = " ;
} ;
}
. " ${ stdenv . hostPlatform . system } "
or ( throw " U n s u p p o r t e d s y s t e m f o r ${ pname } : ${ stdenv . hostPlatform . system } " ) ;
nativeBuildInputs = ( lib . optionals stdenv . hostPlatform . isLinux [ autoPatchelfHook ] ) ++ [
makeWrapper
] ;
buildInputs = [
bash
dejavu_fonts
expat
fontconfig
lato
libGL
nspr
nss
sbclPackages . cl-dejavu
sqlite
] ;
pythonImportsCheck = [ " k a l e i d o " ] ;
postInstall = ''
# Expose kaleido binary
mkdir - p $ out/bin
ln - s $ out / $ { python . sitePackages } /kaleido/executable/bin/kaleido $ out/bin/kaleido
# Replace bundled swiftshader with libGL
rm - rf $ out / $ { python . sitePackages } /kaleido/executable/bin/swiftshader
ln - s $ { libGL } /lib $ out / $ { python . sitePackages } /kaleido/executable/bin/swiftshader
# Relace bundled libraries with nixpkgs-packaged libraries
rm - rf $ out / $ { python . sitePackages } /kaleido/executable/lib
mkdir - p $ out / $ { python . sitePackages } /kaleido/executable/lib
ln - s $ { expat } /lib /* $ o u t / $ { p y t h o n . s i t e P a c k a g e s } / k a l e i d o / e x e c u t a b l e / l i b /
ln - s $ { nspr } /lib /* $ o u t / $ { p y t h o n . s i t e P a c k a g e s } / k a l e i d o / e x e c u t a b l e / l i b /
ln - s $ { nss } /lib /* $ o u t / $ { p y t h o n . s i t e P a c k a g e s } / k a l e i d o / e x e c u t a b l e / l i b /
ln - s $ { sqlite } /lib /* $ o u t / $ { p y t h o n . s i t e P a c k a g e s } / k a l e i d o / e x e c u t a b l e / l i b /
# Replace bundled font configuration with nixpkgs-packaged font configuration
rm - rf $ out / $ { python . sitePackages } /kaleido/executable/etc/fonts
mkdir - p $ out / $ { python . sitePackages } /kaleido/executable/etc/fonts/conf.d
ln - s $ { fontconfig } /etc/fonts/fonts.conf $ out / $ { python . sitePackages } /kaleido/executable/etc/fonts /
ls - s $ { fontconfig } /etc/fonts/conf.d /* $ o u t / $ { p y t h o n . s i t e P a c k a g e s } / k a l e i d o / e x e c u t a b l e / e t c / f o n t s / c o n f . d /
ln - s $ { sbclPackages . cl-dejavu } /dejavu-fonts-ttf-2.37/fontconfig /* $ o u t / $ { p y t h o n . s i t e P a c k a g e s } / k a l e i d o / e x e c u t a b l e / e t c / f o n t s / c o n f . d /
# Replace bundled fonts with nixpkgs-packaged fonts
# Currently this causes an issue where the fonts aren't found. I'm not sure why, so I'm leaving this commented out for now.
#rm -rf $out/${python.sitePackages}/kaleido/executable/xdg/fonts
#mkdir -p $out/${python.sitePackages}/kaleido/executable/xdg/fonts/truetype/dejavu $out/${python.sitePackages}/kaleido/executable/xdg/fonts/truetype/lato
#ln -s ${dejavu_fonts}/share/fonts/truetype/* $out/${python.sitePackages}/kaleido/executable/xdg/fonts/truetype/dejavu/
#ln -s ${lato}/share/fonts/lato/* $out/${python.sitePackages}/kaleido/executable/xdg/fonts/truetype/lato/
'' ;
2024-09-26 11:04:55 +00:00
passthru . tests = lib . optionalAttrs ( ! stdenv . hostPlatform . isDarwin ) {
2024-09-19 14:19:46 +00:00
kaleido = callPackage ./tests.nix { } ;
} ;
meta = {
description = " F a s t s t a t i c i m a g e e x p o r t f o r w e b - b a s e d v i s u a l i z a t i o n l i b r a r i e s w i t h z e r o d e p e n d e n c i e s " ;
homepage = " h t t p s : / / g i t h u b . c o m / p l o t l y / K a l e i d o " ;
changelog = " h t t p s : / / g i t h u b . c o m / p l o t l y / K a l e i d o / r e l e a s e s " ;
platforms = [
" x 8 6 _ 6 4 - l i n u x "
" x 8 6 _ 6 4 - d a r w i n "
" a a r c h 6 4 - l i n u x "
" a a r c h 6 4 - d a r w i n "
] ;
sourceProvenance = with lib . sourceTypes ; [ binaryNativeCode ] ; # Trust me, I'm not happy. But after literal hours of trying to reverse-engineer their build system and getting nowhere, I'll use the stupid binaries >:(
license = lib . licenses . mit ;
maintainers = with lib . maintainers ; [ pandapip1 ] ;
} ;
}