rstudio-server, rstudioServerWrapper: init at rstudio.version (1.4.1717)

Co-authored-by: Justin Bedo <cu@cua0.org>
Co-authored-by: Jonathan Ringer <jonringer@users.noreply.github.com>
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
Co-authored-by: Benjamin Darwin <bcdarwin@gmail.com>
This commit is contained in:
cfhammill 2020-08-19 21:27:10 -04:00 committed by Justin Bedo
parent d3bc05b0f9
commit fd51177e5c
No known key found for this signature in database
GPG Key ID: 2C18202C56C182BD
3 changed files with 182 additions and 138 deletions

View File

@ -1,4 +1,5 @@
{ lib { lib
, stdenv
, mkDerivation , mkDerivation
, fetchurl , fetchurl
, fetchpatch , fetchpatch
@ -30,6 +31,9 @@
, nodejs , nodejs
, mkYarnModules , mkYarnModules
, qmake , qmake
, server ? false # build server version
, sqlite
, pam
}: }:
let let
@ -61,149 +65,165 @@ let
panmirrorModules = mkYarnModules { panmirrorModules = mkYarnModules {
inherit pname version; inherit pname version;
packageJSON = ./package.json; packageJSON = ./package.json;
yarnLock = ./yarn.lock; yarnLock = ./yarn.lock;
yarnNix = ./yarndeps.nix; yarnNix = ./yarndeps.nix;
}; };
description = "Set of integrated tools for the R language";
in in
mkDerivation rec { (if server then stdenv.mkDerivation else mkDerivation)
inherit pname version src RSTUDIO_VERSION_MAJOR RSTUDIO_VERSION_MINOR RSTUDIO_VERSION_PATCH; (rec {
inherit pname version src RSTUDIO_VERSION_MAJOR RSTUDIO_VERSION_MINOR RSTUDIO_VERSION_PATCH;
nativeBuildInputs = [ nativeBuildInputs = [
cmake cmake
unzip unzip
ant ant
jdk jdk
makeWrapper makeWrapper
pandoc pandoc
nodejs nodejs
copyDesktopItems ] ++ lib.optional (!server) [
]; copyDesktopItems
];
buildInputs = [ buildInputs = [
boost boost
zlib zlib
openssl openssl
R R
qtbase libuuid
qtxmlpatterns libyamlcpp
qtsensors soci
qtwebengine postgresql
qtwebchannel ] ++ (if server then [
libuuid sqlite.dev
libyamlcpp pam
soci ] else [
postgresql qtbase
]; qtxmlpatterns
qtsensors
qtwebengine
qtwebchannel
]);
cmakeFlags = [ cmakeFlags = [
"-DRSTUDIO_TARGET=Desktop" "-DRSTUDIO_TARGET=${if server then "Server" else "Desktop"}"
"-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_BUILD_TYPE=Release"
"-DQT_QMAKE_EXECUTABLE=${qmake}/bin/qmake" "-DRSTUDIO_USE_SYSTEM_SOCI=ON"
"-DRSTUDIO_USE_SYSTEM_SOCI=ON" "-DRSTUDIO_USE_SYSTEM_BOOST=ON"
"-DRSTUDIO_USE_SYSTEM_BOOST=ON" "-DRSTUDIO_USE_SYSTEM_YAML_CPP=ON"
"-DRSTUDIO_USE_SYSTEM_YAML_CPP=ON" "-DPANDOC_VERSION=${pandoc.version}"
"-DPANDOC_VERSION=${pandoc.version}" "-DCMAKE_INSTALL_PREFIX=${placeholder "out"}/lib/rstudio"
"-DCMAKE_INSTALL_PREFIX=${placeholder "out"}/lib/rstudio" ] ++ lib.optional (!server) [
]; "-DQT_QMAKE_EXECUTABLE=${qmake}/bin/qmake"
];
# Hack RStudio to only use the input R and provided libclang. # Hack RStudio to only use the input R and provided libclang.
patches = [ patches = [
./r-location.patch ./r-location.patch
./clang-location.patch ./clang-location.patch
# postFetch doesn't work with this | error: unexpected end-of-file # postFetch doesn't work with this | error: unexpected end-of-file
# replacing /usr/bin/node is done in postPatch # replacing /usr/bin/node is done in postPatch
# https://src.fedoraproject.org/rpms/rstudio/tree/rawhide # https://src.fedoraproject.org/rpms/rstudio/tree/rawhide
(fetchpatch { (fetchpatch {
name = "system-node.patch"; name = "system-node.patch";
url = "https://src.fedoraproject.org/rpms/rstudio/raw/5bda2e290c9e72305582f2011040938d3e356906/f/0004-use-system-node.patch"; url = "https://src.fedoraproject.org/rpms/rstudio/raw/5bda2e290c9e72305582f2011040938d3e356906/f/0004-use-system-node.patch";
sha256 = "sha256-P1Y07RB/ceFNa749nyBUWSE41eiiZgt43zVcmahvfZM="; sha256 = "sha256-P1Y07RB/ceFNa749nyBUWSE41eiiZgt43zVcmahvfZM=";
}) })
]; ];
postPatch = '' postPatch = ''
substituteInPlace src/cpp/core/r_util/REnvironmentPosix.cpp --replace '@R@' ${R} substituteInPlace src/cpp/core/r_util/REnvironmentPosix.cpp --replace '@R@' ${R}
substituteInPlace src/cpp/CMakeLists.txt \ substituteInPlace src/cpp/CMakeLists.txt \
--replace 'SOCI_LIBRARY_DIR "/usr/lib"' 'SOCI_LIBRARY_DIR "${soci}/lib"' --replace 'SOCI_LIBRARY_DIR "/usr/lib"' 'SOCI_LIBRARY_DIR "${soci}/lib"'
substituteInPlace src/gwt/build.xml \ substituteInPlace src/gwt/build.xml \
--replace '/usr/bin/node' '${nodejs}/bin/node' --replace '/usr/bin/node' '${nodejs}/bin/node'
substituteInPlace src/cpp/core/libclang/LibClang.cpp \ substituteInPlace src/cpp/core/libclang/LibClang.cpp \
--replace '@libclang@' ${llvmPackages.libclang.lib} \ --replace '@libclang@' ${llvmPackages.libclang.lib} \
--replace '@libclang.so@' ${llvmPackages.libclang.lib}/lib/libclang.so --replace '@libclang.so@' ${llvmPackages.libclang.lib}/lib/libclang.so
substituteInPlace src/cpp/session/include/session/SessionConstants.hpp \ substituteInPlace src/cpp/session/include/session/SessionConstants.hpp \
--replace "bin/pandoc" "${pandoc}/bin/pandoc" --replace "bin/pandoc" "${pandoc}/bin/pandoc"
''; '';
hunspellDictionaries = with lib; filter isDerivation (unique (attrValues hunspellDicts)); hunspellDictionaries = with lib; filter isDerivation (unique (attrValues hunspellDicts));
# These dicts contain identically-named dict files, so we only keep the # These dicts contain identically-named dict files, so we only keep the
# -large versions in case of clashes # -large versions in case of clashes
largeDicts = with lib; filter (d: hasInfix "-large-wordlist" d) hunspellDictionaries; largeDicts = with lib; filter (d: hasInfix "-large-wordlist" d) hunspellDictionaries;
otherDicts = with lib; filter otherDicts = with lib; filter
(d: !(hasAttr "dictFileName" d && (d: !(hasAttr "dictFileName" d &&
elem d.dictFileName (map (d: d.dictFileName) largeDicts))) elem d.dictFileName (map (d: d.dictFileName) largeDicts)))
hunspellDictionaries; hunspellDictionaries;
dictionaries = largeDicts ++ otherDicts; dictionaries = largeDicts ++ otherDicts;
preConfigure = '' preConfigure = ''
mkdir dependencies/dictionaries mkdir dependencies/dictionaries
for dict in ${builtins.concatStringsSep " " dictionaries}; do for dict in ${builtins.concatStringsSep " " dictionaries}; do
for i in "$dict/share/hunspell/"*; do for i in "$dict/share/hunspell/"*; do
ln -s $i dependencies/dictionaries/ ln -s $i dependencies/dictionaries/
done
done done
done
unzip -q ${mathJaxSrc} -d dependencies/mathjax-27 unzip -q ${mathJaxSrc} -d dependencies/mathjax-27
mkdir -p dependencies/pandoc/${pandoc.version} mkdir -p dependencies/pandoc/${pandoc.version}
cp ${pandoc}/bin/pandoc dependencies/pandoc/${pandoc.version}/pandoc cp ${pandoc}/bin/pandoc dependencies/pandoc/${pandoc.version}/pandoc
cp -r ${rsconnectSrc} dependencies/rsconnect cp -r ${rsconnectSrc} dependencies/rsconnect
( cd dependencies && ${R}/bin/R CMD build -d --no-build-vignettes rsconnect ) ( cd dependencies && ${R}/bin/R CMD build -d --no-build-vignettes rsconnect )
cp -r "${panmirrorModules}" src/gwt/panmirror/src/editor/node_modules cp -r "${panmirrorModules}" src/gwt/panmirror/src/editor/node_modules
''; '';
postInstall = '' postInstall = ''
mkdir -p $out/share/icons/hicolor/48x48/apps $out/bin mkdir -p $out/bin $out/share
ln $out/lib/rstudio/rstudio.png $out/share/icons/hicolor/48x48/apps
for f in {diagnostics,rpostback,rstudio}; do ${lib.optionalString (!server) ''
ln -s $out/lib/rstudio/bin/$f $out/bin mkdir -p $out/share/icons/hicolor/48x48/apps
done ln $out/lib/rstudio/rstudio.png $out/share/icons/hicolor/48x48/apps
''}
for f in .gitignore .Rbuildignore LICENSE README; do for f in {${if server
find . -name $f -delete then "crash-handler-proxy,postback,r-ldpath,rpostback,rserver,rserver-pam,rsession,rstudio-server"
done else "diagnostics,rpostback,rstudio"}}; do
rm -r $out/lib/rstudio/{INSTALL,COPYING,NOTICE,README.md,SOURCE,VERSION} ln -s $out/lib/rstudio/bin/$f $out/bin
rm -r $out/lib/rstudio/bin/{pandoc/pandoc,pandoc} done
'';
qtWrapperArgs = [ for f in .gitignore .Rbuildignore LICENSE README; do
"--suffix PATH : ${lib.makeBinPath [ gnumake ]}" 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}
'';
desktopItems = [ meta = with lib; {
(makeDesktopItem { inherit description;
name = "${pname}"; homepage = "https://www.rstudio.com/";
exec = "rstudio %F"; license = licenses.agpl3Only;
icon = "rstudio"; maintainers = with maintainers; [ ciil cfhammill ];
desktopName = "RStudio"; platforms = platforms.linux;
genericName = "IDE"; };
comment = meta.description;
categories = "Development;";
mimeType = "text/x-r-source;text/x-r;text/x-R;text/x-r-doc;text/x-r-sweave;text/x-r-markdown;text/x-r-html;text/x-r-presentation;application/x-r-data;application/x-r-project;text/x-r-history;text/x-r-profile;text/x-tex;text/x-markdown;text/html;text/css;text/javascript;text/x-chdr;text/x-csrc;text/x-c++hdr;text/x-c++src;";
})
];
meta = with lib; { passthru = { inherit server; };
description = "Set of integrated tools for the R language"; } // lib.optionalAttrs (!server) {
homepage = "https://www.rstudio.com/"; qtWrapperArgs = [
license = licenses.agpl3Only; "--suffix PATH : ${lib.makeBinPath [ gnumake ]}"
maintainers = with maintainers; [ ciil ]; ];
platforms = platforms.linux;
}; desktopItems = [
} (makeDesktopItem {
name = pname;
exec = "rstudio %F";
icon = "rstudio";
desktopName = "RStudio";
genericName = "IDE";
comment = description;
categories = "Development;";
mimeType = "text/x-r-source;text/x-r;text/x-R;text/x-r-doc;text/x-r-sweave;text/x-r-markdown;text/x-r-html;text/x-r-presentation;application/x-r-data;application/x-r-project;text/x-r-history;text/x-r-profile;text/x-tex;text/x-markdown;text/html;text/css;text/javascript;text/x-chdr;text/x-csrc;text/x-c++hdr;text/x-c++src;";
})
];
})

View File

@ -1,16 +1,23 @@
{ lib, runCommand, R, rstudio, wrapQtAppsHook, recommendedPackages, packages, qtbase }: { lib
, runCommand
, R
, rstudio
, makeWrapper
, wrapQtAppsHook
, recommendedPackages
, packages
, fontconfig
}:
let runCommand (rstudio.name + "-wrapper")
qtVersion = with lib.versions; "${major qtbase.version}.${minor qtbase.version}"; {
in
runCommand (rstudio.name + "-wrapper") {
preferLocalBuild = true; preferLocalBuild = true;
allowSubstitutes = false; allowSubstitutes = false;
nativeBuildInputs = [wrapQtAppsHook]; nativeBuildInputs = [ (if rstudio.server then makeWrapper else wrapQtAppsHook) ];
dontWrapQtApps = true; dontWrapQtApps = true;
buildInputs = [R rstudio] ++ recommendedPackages ++ packages; buildInputs = [ R rstudio ] ++ recommendedPackages ++ packages;
# rWrapper points R to a specific set of packages by using a wrapper # rWrapper points R to a specific set of packages by using a wrapper
# (as in https://nixos.org/nixpkgs/manual/#r-packages) which sets # (as in https://nixos.org/nixpkgs/manual/#r-packages) which sets
@ -22,14 +29,27 @@ runCommand (rstudio.name + "-wrapper") {
# uses R_PROFILE_USER to load this code at startup in RStudio. # uses R_PROFILE_USER to load this code at startup in RStudio.
fixLibsR = "fix_libs.R"; fixLibsR = "fix_libs.R";
} }
'' (
mkdir $out ''
ln -s ${rstudio}/share $out mkdir -p $out/bin
echo "# Autogenerated by wrapper-rstudio.nix from R_LIBS_SITE" > $out/$fixLibsR ln -s ${rstudio}/share $out
echo -n ".libPaths(c(.libPaths(), \"" >> $out/$fixLibsR echo "# Autogenerated by wrapper-rstudio.nix from R_LIBS_SITE" > $out/$fixLibsR
echo -n $R_LIBS_SITE | sed -e 's/:/", "/g' >> $out/$fixLibsR echo -n ".libPaths(c(.libPaths(), \"" >> $out/$fixLibsR
echo -n "\"))" >> $out/$fixLibsR echo -n $R_LIBS_SITE | sed -e 's/:/", "/g' >> $out/$fixLibsR
echo >> $out/$fixLibsR echo -n "\"))" >> $out/$fixLibsR
makeQtWrapper ${rstudio}/bin/rstudio $out/bin/rstudio \ echo >> $out/$fixLibsR
--set R_PROFILE_USER $out/$fixLibsR '' +
'' (if
rstudio.server then ''
makeWrapper ${rstudio}/bin/rsession $out/bin/rsession \
--set R_PROFILE_USER $out/$fixLibsR --set FONTCONFIG_FILE ${fontconfig.out}/etc/fonts/fonts.conf
makeWrapper ${rstudio}/bin/rserver $out/bin/rserver \
--add-flags --rsession-path=$out/bin/rsession
''
else
''
makeQtWrapper ${rstudio}/bin/rstudio $out/bin/rstudio \
--set R_PROFILE_USER $out/$fixLibsR
'')
)

View File

@ -20754,6 +20754,8 @@ with pkgs;
packages = []; packages = [];
}; };
rstudioServerWrapper = rstudioWrapper.override { rstudio = rstudio-server; };
rPackages = dontRecurseIntoAttrs (callPackage ../development/r-modules { rPackages = dontRecurseIntoAttrs (callPackage ../development/r-modules {
overrides = (config.rPackageOverrides or (_: {})) pkgs; overrides = (config.rPackageOverrides or (_: {})) pkgs;
}); });
@ -28382,6 +28384,8 @@ with pkgs;
jdk = jdk8; jdk = jdk8;
}; };
rstudio-server = rstudio.override { server = true; };
rsync = callPackage ../applications/networking/sync/rsync (config.rsync or {}); rsync = callPackage ../applications/networking/sync/rsync (config.rsync or {});
rrsync = callPackage ../applications/networking/sync/rsync/rrsync.nix {}; rrsync = callPackage ../applications/networking/sync/rsync/rrsync.nix {};