diff --git a/pkgs/applications/editors/rstudio/boost-1.86.patch b/pkgs/applications/editors/rstudio/boost-1.86.patch deleted file mode 100644 index 058eaf42e96d..000000000000 --- a/pkgs/applications/editors/rstudio/boost-1.86.patch +++ /dev/null @@ -1,88 +0,0 @@ -diff --git a/src/cpp/core/json/JsonRpc.cpp b/src/cpp/core/json/JsonRpc.cpp -index d034ffe..4b08486 100644 ---- a/src/cpp/core/json/JsonRpc.cpp -+++ b/src/cpp/core/json/JsonRpc.cpp -@@ -193,7 +193,7 @@ void JsonRpcResponse::setAfterResponse( - - bool JsonRpcResponse::hasAfterResponse() const - { -- return afterResponse_; -+ return !afterResponse_.empty(); - } - - -diff --git a/src/cpp/session/modules/rmarkdown/NotebookExec.cpp b/src/cpp/session/modules/rmarkdown/NotebookExec.cpp -index 5631a1f..0e3030b 100644 ---- a/src/cpp/session/modules/rmarkdown/NotebookExec.cpp -+++ b/src/cpp/session/modules/rmarkdown/NotebookExec.cpp -@@ -193,7 +193,7 @@ void ChunkExecContext::connect() - - // leave an execution lock in this folder so it won't be moved if the notebook - // is saved while executing -- auto lock = make_unique( -+ auto lock = rstudio::core::make_unique( - FileLock::createDefault(), - outputPath_.completePath(kExecutionLock)); - locks_.push_back(std::move(lock)); -@@ -204,7 +204,7 @@ void ChunkExecContext::connect() - initializeOutput(); - - // capture conditions -- auto pConditionCapture = make_unique(); -+ auto pConditionCapture = rstudio::core::make_unique(); - pConditionCapture->connect(); - captures_.push_back(std::move(pConditionCapture)); - connections_.push_back(events().onCondition.connect( -@@ -234,7 +234,7 @@ void ChunkExecContext::connect() - boost::bind(&ChunkExecContext::onFileOutput, this, _1, _2, - _3, ChunkOutputPlot, _4))); - -- auto pPlotCapture = make_unique(); -+ auto pPlotCapture = rstudio::core::make_unique(); - if (figWidth > 0 || figHeight > 0) - { - // user specified plot size, use it -@@ -261,7 +261,7 @@ void ChunkExecContext::connect() - boost::bind(&ChunkExecContext::onFileOutput, this, _1, _2, _3, - ChunkOutputHtml, 0))); - -- auto pHtmlCapture = make_unique(); -+ auto pHtmlCapture = rstudio::core::make_unique(); - error = pHtmlCapture->connectHtmlCapture( - outputPath_, - outputPath_.getParent().completePath(kChunkLibDir), -@@ -316,14 +316,14 @@ void ChunkExecContext::connect() - prevCharWidth_ = r::options::getOptionWidth(); - r::options::setOptionWidth(charWidth_); - -- auto pDirCapture = make_unique(); -+ auto pDirCapture = rstudio::core::make_unique(); - error = pDirCapture->connectDir(docId_, workingDir_); - if (error) - LOG_ERROR(error); - captures_.push_back(std::move(pDirCapture)); - - // begin capturing errors -- auto pErrorCapture = make_unique(); -+ auto pErrorCapture = rstudio::core::make_unique(); - pErrorCapture->connect(); - captures_.push_back(std::move(pErrorCapture)); - -@@ -341,7 +341,7 @@ void ChunkExecContext::connect() - boost::bind(&ChunkExecContext::onFileOutput, this, _1, _2, _3, - ChunkOutputData, 0))); - -- auto pDataCapture = make_unique(); -+ auto pDataCapture = rstudio::core::make_unique(); - error = pDataCapture->connectDataCapture( - outputPath_, - options_.mergedOptions()); -@@ -661,7 +661,7 @@ void ChunkExecContext::initializeOutput() - - // leave an execution lock in this folder so it won't be moved if the notebook - // is saved while executing -- auto lock = make_unique( -+ auto lock = rstudio::core::make_unique( - FileLock::createDefault(), - outputPath.completePath(kExecutionLock)); - locks_.push_back(std::move(lock)); diff --git a/pkgs/applications/editors/rstudio/default.nix b/pkgs/applications/editors/rstudio/default.nix index ff70de589826..8ba7f9df78f5 100644 --- a/pkgs/applications/editors/rstudio/default.nix +++ b/pkgs/applications/editors/rstudio/default.nix @@ -1,47 +1,50 @@ { lib, stdenv, - runCommand, - fetchzip, + + server ? false, # build server version + fetchFromGitHub, + fetchNpmDeps, + fetchYarnDeps, + fetchzip, replaceVars, - cmake, - boost186, - zlib, - openssl, - R, - fontconfig, - quarto, - libuuid, - hunspellDicts, + runCommand, + ant, + cacert, + cmake, + git, jdk, - gnumake, - pandoc, - llvmPackages, - yaml-cpp, - soci, - sqlite, - apple-sdk_11, - xcbuild, + makeWrapper, nodejs, npmHooks, - fetchNpmDeps, + xcbuild, yarn, yarnConfigHook, - fetchYarnDeps, zip, - git, - makeWrapper, + + apple-sdk_11, + boost187, electron_34, - server ? false, # build server version + fontconfig, + gnumake, + hunspellDicts, + libuuid, + llvmPackages, + openssl, pam, + pandoc, + quarto, + R, + soci, + sqlite, + zlib, + nixosTests, }: let - # Note: we shouldn't use the latest electron here, since the node-abi dependency might - # need to be updated every time the latest electron gets a new abi version number electron = electron_34; mathJaxSrc = fetchzip { @@ -53,8 +56,8 @@ let quartoSrc = fetchFromGitHub { owner = "quarto-dev"; repo = "quarto"; - rev = "7d1582d06250216d18696145879415e473a2ae4d"; - hash = "sha256-AaE9EDT3tJieI403QGxAf+A/PEw1rmUdhdpy4WNf40o="; + rev = "8ee12b5d6bd49c7b212eae894bd011ffbeea1c48"; + hash = "sha256-pTrWedYeG2SWQ4jl2fstKjsweWhj4aAvVDiSfkdU3No="; }; hunspellDictionaries = lib.filter lib.isDerivation (lib.unique (lib.attrValues hunspellDicts)); @@ -76,62 +79,106 @@ let in stdenv.mkDerivation rec { pname = "RStudio"; - version = "2024.12.1+563"; - - RSTUDIO_VERSION_MAJOR = lib.versions.major version; - RSTUDIO_VERSION_MINOR = lib.versions.minor version; - RSTUDIO_VERSION_PATCH = lib.versions.patch version; - RSTUDIO_VERSION_SUFFIX = "+" + toString (lib.tail (lib.splitString "+" version)); + version = "2025.05.0+496"; src = fetchFromGitHub { owner = "rstudio"; repo = "rstudio"; tag = "v${version}"; - hash = "sha256-fguomJHs7FBffYfMlgWgnjLWK3uDZYX4Ip4asKZ8XVQ="; + hash = "sha256-yZy/fEYln/jGxErwJiWFgr9w0GvwtMwzpmmHf71chBQ="; + }; + + # sources fetched into _deps via cmake's FetchContent + extSrcs = stdenv.mkDerivation { + name = "${pname}-${version}-ext-srcs"; + inherit src; + + nativeBuildInputs = [ + cacert + cmake + git + ]; + + installPhase = '' + runHook preInstall + + # this will fail, since this is not meant to be a cmake entrypoint + # but it will fetch the dependencies regardless + cmake -S src/cpp/ext -B build || true + + mkdir -p "$out" + cp -r build/_deps/*-src "$out/" + find "$out" -name .git -print0 | xargs -0 rm -rf + + runHook postInstall + ''; + + dontConfigure = true; + dontBuild = true; + dontFixup = true; + + outputHash = "sha256-YW+l0/RZf8ek217pfWTwsR4PTugMGHyW+vaZEwGjMas="; + outputHashAlgo = "sha256"; + outputHashMode = "recursive"; }; nativeBuildInputs = [ cmake + git + ant jdk + nodejs yarn yarnConfigHook zip - git ] - ++ lib.optionals stdenv.hostPlatform.isDarwin [ xcbuild ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + xcbuild + ] ++ lib.optionals (!server) [ + makeWrapper (nodejs.python.withPackages (ps: [ ps.setuptools ])) npmHooks.npmConfigHook - makeWrapper ]; buildInputs = [ - boost186 - zlib + boost187 + libuuid openssl R - libuuid - yaml-cpp soci sqlite.dev ] - ++ lib.optionals stdenv.hostPlatform.isDarwin [ apple-sdk_11 ] - ++ lib.optionals server [ pam ] - ++ lib.optionals (!server) [ fontconfig ]; + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + apple-sdk_11 + ] + ++ lib.optionals (!server) [ + fontconfig + ] + ++ lib.optionals server [ + pam + zlib + ]; cmakeFlags = [ (lib.cmakeFeature "RSTUDIO_TARGET" (if server then "Server" else "Electron")) - (lib.cmakeBool "RSTUDIO_USE_SYSTEM_SOCI" true) + + # don't try fetching the external dependencies already fetched in extSrcs + (lib.cmakeBool "FETCHCONTENT_FULLY_DISCONNECTED" true) + (lib.cmakeBool "RSTUDIO_USE_SYSTEM_BOOST" true) - (lib.cmakeBool "RSTUDIO_USE_SYSTEM_YAML_CPP" true) + (lib.cmakeBool "RSTUDIO_USE_SYSTEM_SOCI" true) + (lib.cmakeBool "RSTUDIO_DISABLE_CHECK_FOR_UPDATES" true) (lib.cmakeBool "QUARTO_ENABLED" true) + (lib.cmakeBool "RSTUDIO_ENABLE_COPILOT" false) # copilot-language-server is unfree (lib.cmakeBool "RSTUDIO_CRASHPAD_ENABLED" false) # This is a NOOP except on x86_64-darwin + (lib.cmakeFeature "CMAKE_INSTALL_PREFIX" ( (placeholder "out") + (if stdenv.hostPlatform.isDarwin then "/Applications" else "/lib/rstudio") )) @@ -140,8 +187,17 @@ stdenv.mkDerivation rec { (lib.cmakeBool "RSTUDIO_INSTALL_FREEDESKTOP" stdenv.hostPlatform.isLinux) ]; - # on Darwin, cmake uses find_library to locate R instead of using the PATH - env.NIX_LDFLAGS = "-L${R}/lib/R/lib"; + env = { + ELECTRON_SKIP_BINARY_DOWNLOAD = "1"; + + # on Darwin, cmake uses find_library to locate R instead of using the PATH + NIX_LDFLAGS = "-L${R}/lib/R/lib"; + + RSTUDIO_VERSION_MAJOR = lib.versions.major version; + RSTUDIO_VERSION_MINOR = lib.versions.minor version; + RSTUDIO_VERSION_PATCH = lib.versions.patch version; + RSTUDIO_VERSION_SUFFIX = "+" + toString (lib.tail (lib.splitString "+" version)); + }; patches = [ # Hack RStudio to only use the input R and provided libclang. @@ -154,10 +210,7 @@ stdenv.mkDerivation rec { ./ignore-etc-os-release.patch ./dont-yarn-install.patch - ./boost-1.86.patch ./fix-darwin.patch - # needed for rebuilding for later electron versions - ./update-nan-and-node-abi.patch ]; postPatch = '' @@ -172,7 +225,7 @@ stdenv.mkDerivation rec { yarnOfflineCache = fetchYarnDeps { yarnLock = quartoSrc + "/yarn.lock"; - hash = "sha256-48Q2MkfzXZSL3ly56WSjRVwU3fgRD8xivQobStBkk6Y="; + hash = "sha256-F+gqVNNhLmyrC+tJuElw7cpx5z/WLHOiYow/y86KR5c="; }; dontYarnInstallDeps = true; # will call manually in preConfigure @@ -187,14 +240,16 @@ stdenv.mkDerivation rec { npmDeps = fetchNpmDeps { name = "rstudio-${version}-npm-deps"; inherit src; - patches = [ ./update-nan-and-node-abi.patch ]; postPatch = "cd ${npmRoot}"; - hash = "sha256-9VHse+nxr5A1EWuszQ6cnJAMqYiHFqHQ4OJ/TJq+XoI="; + hash = "sha256-ispV6FJdtOELtFNIZDn1lKbwvO/iTO8mrZ8nIOs2uhs="; }; - env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1"; - preConfigure = '' + # populate the directories used by cmake's FetchContent + mkdir -p build/_deps + cp -r "$extSrcs"/* build/_deps + chmod -R u+w build/_deps + # set up node_modules directory inside quarto so that panmirror can be built mkdir src/gwt/lib/quarto cp -r --no-preserve=all ${quartoSrc}/* src/gwt/lib/quarto @@ -221,12 +276,7 @@ stdenv.mkDerivation rec { mkdir -p dependencies/common/node # node used by cmake # version in cmake/globals.cmake (RSTUDIO_NODE_VERSION) - ln -s ${nodejs} dependencies/common/node/20.15.1 - - # node used at runtime - # version in cmake/globals.cmake (RSTUDIO_INSTALLED_NODE_VERSION) - # upstream uses the -patched suffix for the runtime node directory - ln -s ${nodejs} dependencies/common/node/20.15.1-patched + ln -s ${nodejs} dependencies/common/node/22.13.1 ${lib.optionalString (!server) '' pushd $npmRoot @@ -301,12 +351,13 @@ stdenv.mkDerivation rec { passthru = { inherit server; - tests = { + tests = lib.optionalAttrs stdenv.hostPlatform.isLinux { inherit (nixosTests) rstudio-server; }; }; meta = { + changelog = "https://github.com/rstudio/rstudio/tree/${src.rev}/version/news"; description = "Set of integrated tools for the R language"; homepage = "https://www.rstudio.com/"; license = lib.licenses.agpl3Only; @@ -316,6 +367,7 @@ stdenv.mkDerivation rec { tomasajt ]; mainProgram = "rstudio" + lib.optionalString server "-server"; - platforms = lib.platforms.linux ++ lib.platforms.darwin; + # rstudio-server on darwin is only partially supported by upstream + platforms = lib.platforms.linux ++ lib.optionals (!server) lib.platforms.darwin; }; } diff --git a/pkgs/applications/editors/rstudio/update-nan-and-node-abi.patch b/pkgs/applications/editors/rstudio/update-nan-and-node-abi.patch deleted file mode 100644 index bdb62dfa8a5e..000000000000 --- a/pkgs/applications/editors/rstudio/update-nan-and-node-abi.patch +++ /dev/null @@ -1,70 +0,0 @@ -diff --git a/src/node/desktop/package-lock.json b/src/node/desktop/package-lock.json -index a210521..9543abb 100644 ---- a/src/node/desktop/package-lock.json -+++ b/src/node/desktop/package-lock.json -@@ -18,7 +18,7 @@ - "line-reader": "0.4.0", - "lodash.debounce": "4.0.8", - "net-ipc": "2.2.0", -- "node-abi": "3.71.0", -+ "node-abi": "^3.74.0", - "node-addon-api": "8.3.0", - "node-system-fonts": "1.0.1", - "properties-reader": "2.3.0", -@@ -56,7 +56,7 @@ - "json-schema-to-typescript": "14.1.0", - "lint-staged": "15.2.10", - "mocha": "10.8.2", -- "nan": "2.22.0", -+ "nan": "^2.22.1", - "node-loader": "2.1.0", - "nyc": "17.1.0", - "prettier": "3.3.3", -@@ -9538,9 +9538,9 @@ - } - }, - "node_modules/nan": { -- "version": "2.22.0", -- "resolved": "https://registry.npmjs.org/nan/-/nan-2.22.0.tgz", -- "integrity": "sha512-nbajikzWTMwsW+eSsNm3QwlOs7het9gGJU5dDZzRTQGk03vyBOauxgI4VakDzE0PtsGTmXPsXTbbjVhRwR5mpw==", -+ "version": "2.22.1", -+ "resolved": "https://registry.npmjs.org/nan/-/nan-2.22.1.tgz", -+ "integrity": "sha512-pfRR4ZcNTSm2ZFHaztuvbICf+hyiG6ecA06SfAxoPmuHjvMu0KUIae7Y8GyVkbBqeEIidsmXeYooWIX9+qjfRQ==", - "license": "MIT" - }, - "node_modules/nanoid": { -@@ -9667,9 +9667,9 @@ - } - }, - "node_modules/node-abi": { -- "version": "3.71.0", -- "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.71.0.tgz", -- "integrity": "sha512-SZ40vRiy/+wRTf21hxkkEjPJZpARzUMVcJoQse2EF8qkUWbbO2z7vd5oA/H6bVH6SZQ5STGcu0KRDS7biNRfxw==", -+ "version": "3.74.0", -+ "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.74.0.tgz", -+ "integrity": "sha512-c5XK0MjkGBrQPGYG24GBADZud0NCbznxNx0ZkS+ebUTrmV1qTDxPxSL8zEAPURXSbLRWVexxmP4986BziahL5w==", - "license": "MIT", - "dependencies": { - "semver": "^7.3.5" -diff --git a/src/node/desktop/package.json b/src/node/desktop/package.json -index 8b8ef47..287d879 100644 ---- a/src/node/desktop/package.json -+++ b/src/node/desktop/package.json -@@ -54,7 +54,7 @@ - "json-schema-to-typescript": "14.1.0", - "lint-staged": "15.2.10", - "mocha": "10.8.2", -- "nan": "2.22.0", -+ "nan": "^2.22.1", - "node-loader": "2.1.0", - "nyc": "17.1.0", - "prettier": "3.3.3", -@@ -76,7 +76,7 @@ - "line-reader": "0.4.0", - "lodash.debounce": "4.0.8", - "net-ipc": "2.2.0", -- "node-abi": "3.71.0", -+ "node-abi": "^3.74.0", - "node-addon-api": "8.3.0", - "node-system-fonts": "1.0.1", - "properties-reader": "2.3.0",