@ -1,4 +1,5 @@
{ lib
, stdenv
, mkDerivation
, fetchurl
, fetchpatch
@ -30,6 +31,9 @@
, nodejs
, mkYarnModules
, qmake
, server ? false # build server version
, sqlite
, pam
} :
let
@ -61,149 +65,165 @@ let
panmirrorModules = mkYarnModules {
inherit pname version ;
packageJSON = ./package.json ;
yarnLock = ./yarn.lock ;
yarnLock = ./yarn.lock ;
yarnNix = ./yarndeps.nix ;
} ;
description = " S e t o f i n t e g r a t e d t o o l s f o r t h e R l a n g u a g e " ;
in
mkDerivation rec {
inherit pname version src RSTUDIO_VERSION_MAJOR RSTUDIO_VERSION_MINOR RSTUDIO_VERSION_PATCH ;
nativeBuildInputs = [
cmake
unzip
ant
jdk
makeWrapper
pandoc
nodejs
copyDesktopItems
] ;
buildInputs = [
boost
zlib
openssl
R
qtbase
qtxmlpatterns
qtsensors
qtwebengine
qtwebchannel
libuuid
libyamlcpp
soci
postgresql
] ;
cmakeFlags = [
" - D R S T U D I O _ T A R G E T = D e s k t o p "
" - D C M A K E _ B U I L D _ T Y P E = R e l e a s e "
" - D Q T _ Q M A K E _ E X E C U T A B L E = ${ qmake } / b i n / q m a k e "
" - D R S T U D I O _ U S E _ S Y S T E M _ S O C I = O N "
" - D R S T U D I O _ U S E _ S Y S T E M _ B O O S T = O N "
" - D R S T U D I O _ U S E _ S Y S T E M _ Y A M L _ C P P = O N "
" - D P A N D O C _ V E R S I O N = ${ pandoc . version } "
" - D C M A K E _ I N S T A L L _ P R E F I X = ${ placeholder " o u t " } / l i b / r s t u d i o "
] ;
# Hack RStudio to only use the input R and provided libclang.
patches = [
./r-location.patch
./clang-location.patch
# postFetch doesn't work with this | error: unexpected end-of-file
# replacing /usr/bin/node is done in postPatch
# https://src.fedoraproject.org/rpms/rstudio/tree/rawhide
( fetchpatch {
name = " s y s t e m - n o d e . p a t c h " ;
url = " h t t p s : / / s r c . f e d o r a p r o j e c t . o r g / r p m s / r s t u d i o / r a w / 5 b d a 2 e 2 9 0 c 9 e 7 2 3 0 5 5 8 2 f 2 0 1 1 0 4 0 9 3 8 d 3 e 3 5 6 9 0 6 / f / 0 0 0 4 - u s e - s y s t e m - n o d e . p a t c h " ;
sha256 = " s h a 2 5 6 - P 1 Y 0 7 R B / c e F N a 7 4 9 n y B U W S E 4 1 e i i Z g t 4 3 z V c m a h v f Z M = " ;
} )
] ;
postPatch = ''
substituteInPlace src/cpp/core/r_util/REnvironmentPosix.cpp - - replace ' @ R @ ' $ { R }
substituteInPlace src/cpp/CMakeLists.txt \
- - replace ' SOCI_LIBRARY_DIR " / u s r / l i b " ' ' SOCI_LIBRARY_DIR " ${ soci } / l i b " '
substituteInPlace src/gwt/build.xml \
- - replace ' /usr/bin/node ' ' $ { nodejs } /bin/node '
substituteInPlace src/cpp/core/libclang/LibClang.cpp \
- - replace ' @ libclang @ ' $ { llvmPackages . libclang . lib } \
- - replace ' @ libclang . so @ ' $ { llvmPackages . libclang . lib } /lib/libclang.so
substituteInPlace src/cpp/session/include/session/SessionConstants.hpp \
- - replace " b i n / p a n d o c " " ${ pandoc } / b i n / p a n d o c "
'' ;
hunspellDictionaries = with lib ; filter isDerivation ( unique ( attrValues hunspellDicts ) ) ;
# These dicts contain identically-named dict files, so we only keep the
# -large versions in case of clashes
largeDicts = with lib ; filter ( d : hasInfix " - l a r g e - w o r d l i s t " d ) hunspellDictionaries ;
otherDicts = with lib ; filter
( d : ! ( hasAttr " d i c t F i l e N a m e " d &&
elem d . dictFileName ( map ( d : d . dictFileName ) largeDicts ) ) )
hunspellDictionaries ;
dictionaries = largeDicts ++ otherDicts ;
preConfigure = ''
mkdir dependencies/dictionaries
for dict in $ { builtins . concatStringsSep " " dictionaries } ; do
for i in " $ d i c t / s h a r e / h u n s p e l l / " * ; do
ln - s $ i dependencies/dictionaries /
( if server then stdenv . mkDerivation else mkDerivation )
( rec {
inherit pname version src RSTUDIO_VERSION_MAJOR RSTUDIO_VERSION_MINOR RSTUDIO_VERSION_PATCH ;
nativeBuildInputs = [
cmake
unzip
ant
jdk
makeWrapper
pandoc
nodejs
] ++ lib . optional ( ! server ) [
copyDesktopItems
] ;
buildInputs = [
boost
zlib
openssl
R
libuuid
libyamlcpp
soci
postgresql
] ++ ( if server then [
sqlite . dev
pam
] else [
qtbase
qtxmlpatterns
qtsensors
qtwebengine
qtwebchannel
] ) ;
cmakeFlags = [
" - D R S T U D I O _ T A R G E T = ${ if server then " S e r v e r " else " D e s k t o p " } "
" - D C M A K E _ B U I L D _ T Y P E = R e l e a s e "
" - D R S T U D I O _ U S E _ S Y S T E M _ S O C I = O N "
" - D R S T U D I O _ U S E _ S Y S T E M _ B O O S T = O N "
" - D R S T U D I O _ U S E _ S Y S T E M _ Y A M L _ C P P = O N "
" - D P A N D O C _ V E R S I O N = ${ pandoc . version } "
" - D C M A K E _ I N S T A L L _ P R E F I X = ${ placeholder " o u t " } / l i b / r s t u d i o "
] ++ lib . optional ( ! server ) [
" - D Q T _ Q M A K E _ E X E C U T A B L E = ${ qmake } / b i n / q m a k e "
] ;
# Hack RStudio to only use the input R and provided libclang.
patches = [
./r-location.patch
./clang-location.patch
# postFetch doesn't work with this | error: unexpected end-of-file
# replacing /usr/bin/node is done in postPatch
# https://src.fedoraproject.org/rpms/rstudio/tree/rawhide
( fetchpatch {
name = " s y s t e m - n o d e . p a t c h " ;
url = " h t t p s : / / s r c . f e d o r a p r o j e c t . o r g / r p m s / r s t u d i o / r a w / 5 b d a 2 e 2 9 0 c 9 e 7 2 3 0 5 5 8 2 f 2 0 1 1 0 4 0 9 3 8 d 3 e 3 5 6 9 0 6 / f / 0 0 0 4 - u s e - s y s t e m - n o d e . p a t c h " ;
sha256 = " s h a 2 5 6 - P 1 Y 0 7 R B / c e F N a 7 4 9 n y B U W S E 4 1 e i i Z g t 4 3 z V c m a h v f Z M = " ;
} )
] ;
postPatch = ''
substituteInPlace src/cpp/core/r_util/REnvironmentPosix.cpp - - replace ' @ R @ ' $ { R }
substituteInPlace src/cpp/CMakeLists.txt \
- - replace ' SOCI_LIBRARY_DIR " / u s r / l i b " ' ' SOCI_LIBRARY_DIR " ${ soci } / l i b " '
substituteInPlace src/gwt/build.xml \
- - replace ' /usr/bin/node ' ' $ { nodejs } /bin/node '
substituteInPlace src/cpp/core/libclang/LibClang.cpp \
- - replace ' @ libclang @ ' $ { llvmPackages . libclang . lib } \
- - replace ' @ libclang . so @ ' $ { llvmPackages . libclang . lib } /lib/libclang.so
substituteInPlace src/cpp/session/include/session/SessionConstants.hpp \
- - replace " b i n / p a n d o c " " ${ pandoc } / b i n / p a n d o c "
'' ;
hunspellDictionaries = with lib ; filter isDerivation ( unique ( attrValues hunspellDicts ) ) ;
# These dicts contain identically-named dict files, so we only keep the
# -large versions in case of clashes
largeDicts = with lib ; filter ( d : hasInfix " - l a r g e - w o r d l i s t " d ) hunspellDictionaries ;
otherDicts = with lib ; filter
( d : ! ( hasAttr " d i c t F i l e N a m e " d &&
elem d . dictFileName ( map ( d : d . dictFileName ) largeDicts ) ) )
hunspellDictionaries ;
dictionaries = largeDicts ++ otherDicts ;
preConfigure = ''
mkdir dependencies/dictionaries
for dict in $ { builtins . concatStringsSep " " dictionaries } ; do
for i in " $ d i c t / s h a r e / h u n s p e l l / " * ; do
ln - s $ i dependencies/dictionaries /
done
done
done
unzip - q $ { mathJaxSrc } - d dependencies/mathjax-27
mkdir - p dependencies/pandoc / $ { pandoc . version }
cp $ { pandoc } /bin/pandoc dependencies/pandoc / $ { pandoc . version } /pandoc
cp - r $ { rsconnectSrc } dependencies/rsconnect
( cd dependencies && $ { R } /bin/R CMD build - d - - no-build-vignettes rsconnect )
cp - r " ${ panmirrorModules } " src/gwt/panmirror/src/editor/node_modules
'' ;
postInstall = ''
mkdir - p $ out/share/icons/hicolor/48x48/apps $ out/bin
ln $ out/lib/rstudio/rstudio.png $ out/share/icons/hicolor/48x48/apps
for f in { diagnostics , rpostback , rstudio } ; do
ln - s $ out/lib/rstudio/bin / $ f $ out/bin
done
for f in . gitignore . Rbuildignore LICENSE README ; do
find . - name $ f - delete
done
rm - r $ out/lib/rstudio / { INSTALL , COPYING , NOTICE , README . md , SOURCE , VERSION }
rm - r $ out/lib/rstudio/bin / { pandoc/pandoc , pandoc }
'' ;
qtWrapperArgs = [
" - - s u f f i x P A T H : ${ lib . makeBinPath [ gnumake ] } "
] ;
desktopItems = [
( makeDesktopItem {
name = " ${ pname } " ;
exec = " r s t u d i o % F " ;
icon = " r s t u d i o " ;
desktopName = " R S t u d i o " ;
genericName = " I D E " ;
comment = meta . description ;
categories = " D e v e l o p m e n t ; " ;
mimeType = " t e x t / x - r - s o u r c e ; t e x t / x - r ; t e x t / x - R ; t e x t / x - r - d o c ; t e x t / x - r - s w e a v e ; t e x t / x - r - m a r k d o w n ; t e x t / x - r - h t m l ; t e x t / x - r - p r e s e n t a t i o n ; a p p l i c a t i o n / x - r - d a t a ; a p p l i c a t i o n / x - r - p r o j e c t ; t e x t / x - r - h i s t o r y ; t e x t / x - r - p r o f i l e ; t e x t / x - t e x ; t e x t / x - m a r k d o w n ; t e x t / h t m l ; t e x t / c s s ; t e x t / j a v a s c r i p t ; t e x t / x - c h d r ; t e x t / x - c s r c ; t e x t / x - c + + h d r ; t e x t / x - c + + s r c ; " ;
} )
] ;
meta = with lib ; {
description = " S e t o f i n t e g r a t e d t o o l s f o r t h e R l a n g u a g e " ;
homepage = " h t t p s : / / w w w . r s t u d i o . c o m / " ;
license = licenses . agpl3Only ;
maintainers = with maintainers ; [ ciil ] ;
platforms = platforms . linux ;
} ;
}
unzip - q $ { mathJaxSrc } - d dependencies/mathjax-27
mkdir - p dependencies/pandoc / $ { pandoc . version }
cp $ { pandoc } /bin/pandoc dependencies/pandoc / $ { pandoc . version } /pandoc
cp - r $ { rsconnectSrc } dependencies/rsconnect
( cd dependencies && $ { R } /bin/R CMD build - d - - no-build-vignettes rsconnect )
cp - r " ${ panmirrorModules } " src/gwt/panmirror/src/editor/node_modules
'' ;
postInstall = ''
mkdir - p $ out/bin $ out/share
$ { lib . optionalString ( ! server ) ''
mkdir - p $ out/share/icons/hicolor/48x48/apps
ln $ out/lib/rstudio/rstudio.png $ out/share/icons/hicolor/48x48/apps
'' }
for f in { ${ if server
then " c r a s h - h a n d l e r - p r o x y , p o s t b a c k , r - l d p a t h , r p o s t b a c k , r s e r v e r , r s e r v e r - p a m , r s e s s i o n , r s t u d i o - s e r v e r "
else " d i a g n o s t i c s , r p o s t b a c k , r s t u d i o " } } ; do
ln - s $ out/lib/rstudio/bin / $ f $ out/bin
done
for f in . gitignore . Rbuildignore LICENSE README ; do
find . - name $ f - delete
done
rm - r $ out/lib/rstudio / { INSTALL , COPYING , NOTICE , README . md , SOURCE , VERSION }
rm - r $ out/lib/rstudio/bin / { pandoc/pandoc , pandoc }
'' ;
meta = with lib ; {
inherit description ;
homepage = " h t t p s : / / w w w . r s t u d i o . c o m / " ;
license = licenses . agpl3Only ;
maintainers = with maintainers ; [ ciil cfhammill ] ;
platforms = platforms . linux ;
} ;
passthru = { inherit server ; } ;
} // lib . optionalAttrs ( ! server ) {
qtWrapperArgs = [
" - - s u f f i x P A T H : ${ lib . makeBinPath [ gnumake ] } "
] ;
desktopItems = [
( makeDesktopItem {
name = pname ;
exec = " r s t u d i o % F " ;
icon = " r s t u d i o " ;
desktopName = " R S t u d i o " ;
genericName = " I D E " ;
comment = description ;
categories = " D e v e l o p m e n t ; " ;
mimeType = " t e x t / x - r - s o u r c e ; t e x t / x - r ; t e x t / x - R ; t e x t / x - r - d o c ; t e x t / x - r - s w e a v e ; t e x t / x - r - m a r k d o w n ; t e x t / x - r - h t m l ; t e x t / x - r - p r e s e n t a t i o n ; a p p l i c a t i o n / x - r - d a t a ; a p p l i c a t i o n / x - r - p r o j e c t ; t e x t / x - r - h i s t o r y ; t e x t / x - r - p r o f i l e ; t e x t / x - t e x ; t e x t / x - m a r k d o w n ; t e x t / h t m l ; t e x t / c s s ; t e x t / j a v a s c r i p t ; t e x t / x - c h d r ; t e x t / x - c s r c ; t e x t / x - c + + h d r ; t e x t / x - c + + s r c ; " ;
} )
] ;
} )