push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1 @@
Moved to [/doc/languages-frameworks/r.section.md](/doc/languages-frameworks/r.section.md)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,117 @@
#!/usr/bin/env Rscript
# This script can be used to generate the .json file for a given R package set
# that is part of the `rPackages` tree
#
# See R section of the nixpkgs manual for an example of how to use this script
library(data.table)
library(parallel)
library(BiocManager)
library(jsonlite)
# always order strings according to POSIX ordering
locale <- Sys.setlocale(locale = "C")
biocVersion <- BiocManager:::.version_map()
biocVersion <- biocVersion[biocVersion$R == getRversion()[, 1:2],c("Bioc", "BiocStatus")]
if ("release" %in% biocVersion$BiocStatus) {
biocVersion <- as.character(biocVersion[biocVersion$BiocStatus == "release", "Bioc"])
} else {
biocVersion <- max(as.character(biocVersion$Bioc))
}
mirrorUrls <- list( bioc=paste0("http://bioconductor.org/packages/", biocVersion, "/bioc/src/contrib/")
, "bioc-annotation"=paste0("http://bioconductor.org/packages/", biocVersion, "/data/annotation/src/contrib/")
, "bioc-experiment"=paste0("http://bioconductor.org/packages/", biocVersion, "/data/experiment/src/contrib/")
, cran="https://cran.r-project.org/src/contrib/"
)
mirrorType <- commandArgs(trailingOnly=TRUE)[1]
stopifnot(mirrorType %in% names(mirrorUrls))
packagesFile <- paste(mirrorType, 'packages.json', sep='-')
prevPkgs <- fromJSON(packagesFile)$packages
write(paste("downloading package lists"), stderr())
pkgTables <- lapply(mirrorUrls, function(url) as.data.table(available.packages(url, filters=c("R_version", "OS_type", "duplicates")), method="libcurl"))
knownPackageNames <- c(unique(do.call("rbind", pkgTables)$Package))
pkgTable <- pkgTables[mirrorType][[1]]
mirrorUrl <- mirrorUrls[mirrorType][[1]]
escapeName <- function(name) {
gsub(".", "_", switch(name, "import" = "r_import", "assert" = "r_assert", name), fixed=TRUE)
}
nixPrefetch <- function(name, version) {
prevPkg <- prevPkgs[[escapeName(name)]]
if (!is.null(prevPkg) && prevPkg$version == version)
prevPkg$sha256
else {
# avoid nix-prefetch-url because it often fails to fetch/hash large files
url <- paste0(mirrorUrl, name, "_", version, ".tar.gz")
tmp <- tempfile(pattern=paste0(name, "_", version), fileext=".tar.gz")
cmd <- paste0("wget -q -O '", tmp, "' '", url, "'")
if(mirrorType == "cran"){
archiveUrl <- paste0(mirrorUrl, "Archive/", name, "/", name, "_", version, ".tar.gz")
cmd <- paste0(cmd, " || wget -q -O '", tmp, "' '", archiveUrl, "'")
}
cmd <- paste0(cmd, " && nix-hash --type sha256 --base32 --flat '", tmp, "'")
cmd <- paste0(cmd, " && echo >&2 ' added ", name, " v", version, "'")
cmd <- paste0(cmd, " ; rm -rf '", tmp, "'")
system(cmd, intern=TRUE)
}
}
formatPackage <- function(name, version, sha256, depends, imports, linkingTo) {
options(warn=5)
depends <- paste( if (is.na(depends)) "" else gsub("[ \t\n]+", "", depends)
, if (is.na(imports)) "" else gsub("[ \t\n]+", "", imports)
, if (is.na(linkingTo)) "" else gsub("[ \t\n]+", "", linkingTo)
, sep=","
)
depends <- unlist(strsplit(depends, split=",", fixed=TRUE))
depends <- lapply(depends, gsub, pattern="([^ \t\n(]+).*", replacement="\\1")
depends <- depends[depends %in% knownPackageNames]
depends <- lapply(depends, escapeName)
depends <- paste(depends)
depends <- sort(unique(depends))
list(name=unbox(name), version=unbox(version), sha256=unbox(sha256), depends=depends)
}
cl <- makeCluster(10)
clusterExport(cl, c("escapeName", "nixPrefetch", "prevPkgs", "mirrorUrl", "mirrorType", "knownPackageNames"))
write(paste("updating", mirrorType, "packages"), stderr())
pkgTable$sha256 <- parApply(cl, pkgTable, 1, function(p) nixPrefetch(p[1], p[2]))
stopCluster(cl)
pkgs <- lapply(1:nrow(pkgTable), function(i) with(pkgTable[i,], formatPackage(Package, Version, sha256, Depends, Imports, LinkingTo)))
names(pkgs) <- lapply(pkgs, function(p) escapeName(p$name))
# Mark deleted packages as broken
brokenPkgs <- lapply(prevPkgs[setdiff(names(prevPkgs), names(pkgs))], function(p)
list(name=unbox(p$name),
version=unbox(p$version),
sha256=unbox(p$sha256),
depends=p$depends,
broken=unbox(T)))
# sort packages by their non-escaped names
pkgs <- pkgs[order(sapply(pkgs, function(p) p$name))]
brokenPkgs<- brokenPkgs[order(sapply(brokenPkgs, function(p) p$name))]
# empty named list
extraArgs = setNames(list(), character(0))
if (mirrorType != "cran") {
extraArgs=list(biocVersion=unbox(paste(biocVersion)))
}
cat(toJSON(list(extraArgs=extraArgs, packages=c(pkgs, brokenPkgs)), pretty=TRUE))
cat("\n")
write("done", stderr())

View File

@@ -0,0 +1,24 @@
with import ../../.. { };
stdenv.mkDerivation {
name = "generate-r-packages-shell";
buildCommand = "exit 1";
buildInputs = [
wget
cacert
nix
];
nativeBuildInputs = [
(rWrapper.override {
packages = with rPackages; [
data_table
parallel
BiocManager
jsonlite
];
})
];
}

View File

@@ -0,0 +1,83 @@
{
stdenv,
lib,
R,
xvfb-run,
util-linux,
gettext,
gfortran,
libiconv,
}:
{
name,
buildInputs ? [ ],
requireX ? false,
...
}@attrs:
stdenv.mkDerivation (
{
buildInputs =
buildInputs
++ [
R
gettext
]
++ lib.optionals requireX [
util-linux
xvfb-run
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
gfortran
libiconv
];
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-I${lib.getInclude stdenv.cc.libcxx}/include/c++/v1";
enableParallelBuilding = true;
configurePhase = ''
runHook preConfigure
export MAKEFLAGS+="''${enableParallelBuilding:+-j$NIX_BUILD_CORES}"
export R_LIBS_SITE="$R_LIBS_SITE''${R_LIBS_SITE:+:}$out/library"
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
runHook postBuild
'';
installFlags = if attrs.doCheck or true then [ ] else [ "--no-test-load" ];
rCommand =
if requireX then
# Unfortunately, xvfb-run has a race condition even with -a option, so that
# we acquire a lock explicitly.
"flock ${xvfb-run} xvfb-run -a -e xvfb-error R"
else
"R";
installPhase = ''
runHook preInstall
mkdir -p $out/library
$rCommand CMD INSTALL --built-timestamp='1970-01-01 00:00:00 UTC' $installFlags --configure-args="$configureFlags" -l $out/library .
runHook postInstall
'';
postFixup = ''
if test -e $out/nix-support/propagated-build-inputs; then
ln -s $out/nix-support/propagated-build-inputs $out/nix-support/propagated-user-env-packages
fi
'';
checkPhase = ''
# noop since R CMD INSTALL tests packages
'';
}
// attrs
// {
name = "r-" + name;
}
)

View File

@@ -0,0 +1,48 @@
diff --git a/src/ucsc/common.c b/src/ucsc/common.c
index a3fc893..e4198d3 100644
--- a/src/ucsc/common.c
+++ b/src/ucsc/common.c
@@ -341,7 +341,7 @@ if (count > 1)
}
}
-void slUniqify(void *pList, int (*compare )(const void *elem1, const void *elem2), void (*free)())
+void slUniqify(void *pList, int (*compare )(const void *elem1, const void *elem2), void (*freeFunc)())
/* Return sorted list with duplicates removed.
* Compare should be same type of function as slSort's compare (taking
* pointers to pointers to elements. Free should take a simple
@@ -356,7 +356,7 @@ while ((el = slPopHead(&oldList)) != NULL)
{
if ((newList == NULL) || (compare(&newList, &el) != 0))
slAddHead(&newList, el);
- else if (free != NULL)
+ else if (freeFunc != NULL)
free(el);
}
slReverse(&newList);
diff --git a/src/ucsc/hash.c b/src/ucsc/hash.c
index 320b360..6ed9c70 100644
--- a/src/ucsc/hash.c
+++ b/src/ucsc/hash.c
@@ -611,7 +611,7 @@ if ((hash = *pHash) != NULL)
}
}
-void hashFreeWithVals(struct hash **pHash, void (freeFunc)())
+void hashFreeWithVals(struct hash **pHash, void (*freeFunc)(void **))
/* Free up hash table and all values associated with it. freeFunc is a
* function to free an entry, should take a pointer to a pointer to an
* entry. */
diff --git a/src/ucsc/hash.h b/src/ucsc/hash.h
index a7fc017..0d06bb9 100644
--- a/src/ucsc/hash.h
+++ b/src/ucsc/hash.h
@@ -244,7 +244,7 @@ void freeHashAndVals(struct hash **pHash);
/* Free up hash table and all values associated with it.
* (Just calls freeMem on each hel->val) */
-void hashFreeWithVals(struct hash **pHash, void (freeFunc)());
+void hashFreeWithVals(struct hash **pHash, void (*freeFunc)(void **));
/* Free up hash table and all values associated with it. freeFunc is a
* function to free an entry, should take a pointer to a pointer to an
* entry. */

View File

@@ -0,0 +1,17 @@
diff --git a/src/Makevars b/src/Makevars
index 4f3fa42ce752..e48e45561292 100755
--- a/src/Makevars
+++ b/src/Makevars
@@ -24,12 +24,6 @@ FILES = $(CFILES) $(CPPFILES)
SOURCES = $(FILES)
OBJECTS = $(CPPFILES:.cpp=.o) $(CFILES:.c=.o)
-strippedLib: $(SHLIB)
- if test -e "/usr/bin/strip" & test -e "/bin/uname" & [[ `uname` == "Linux" ]] ; then /usr/bin/strip --strip-debug $(SHLIB); fi
-clean:
- rm $(OBJECTS)
-.phony: strippedLib clean
-
RHTSLIB_LIBS=$(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript" -e \
'Rhtslib::pkgconfig("PKG_LIBS")')
RHTSLIB_CPPFLAGS=$(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript" -e \

View File

@@ -0,0 +1,20 @@
diff -ru -x '*~' RAppArmor_orig/configure RAppArmor/configure
--- RAppArmor_orig/configure 2013-12-17 11:23:00.000000000 +0900
+++ RAppArmor/configure 2014-10-18 22:22:39.641341244 +0900
@@ -1,15 +1,2 @@
-if [ ! -e /usr/include/sys/apparmor.h ]
-then
- echo "sys/apparmor.h not found. Make sure libapparmor-dev is installed."
- exit 1
-fi
-
-LIBFILE=$(/sbin/ldconfig -p | egrep -oh " [-_a-zA-Z0-9/]*/libapparmor.so(.1)?$")
-
-if [ -z "$LIBFILE" ]
-then
- echo "libapparmor.so not found. Make sure libapparmor-dev is installed."
- exit 1
-fi
-
+LIBFILE="$LIBAPPARMOR_HOME/lib/libapparmor.so.1"
echo "PKG_LIBS="$LIBFILE > src/Makevars

View File

@@ -0,0 +1,79 @@
diff --git a/R/zzz.R b/R/zzz.R
index 97becd7..803ca39 100644
--- a/R/zzz.R
+++ b/R/zzz.R
@@ -20,7 +20,7 @@ pkgconfig <- function(opt = c("PKG_CXX_LIBS", "PKG_C_LIBS", "PKG_CXX_HL_LIBS", "
path <- Sys.getenv(
x = "RHDF5LIB_RPATH",
- unset = system.file("lib", package="Rhdf5lib", mustWork=TRUE)
+ unset = ""
)
if (nzchar(.Platform$r_arch)) {
@@ -59,7 +59,7 @@ pkgconfig <- function(opt = c("PKG_CXX_LIBS", "PKG_C_LIBS", "PKG_CXX_HL_LIBS", "
sprintf('-L%s -lhdf5 %s',
patharch, winlibs)
}, {
- sprintf('"%s/libhdf5.a"%s%s',
+ sprintf('-lhdf5',
patharch, .getSzipLoc(patharch), .getDynamicLinks())
}
)
@@ -70,7 +70,7 @@ pkgconfig <- function(opt = c("PKG_CXX_LIBS", "PKG_C_LIBS", "PKG_CXX_HL_LIBS", "
sprintf('-L%s -lhdf5_cpp -lhdf5 %s',
patharch, winlibs)
}, {
- sprintf('"%s/libhdf5_cpp.a" "%s/libhdf5.a"%s%s',
+ sprintf('-lhdf5_cpp -lhdf5',
patharch, patharch, .getSzipLoc(patharch), .getDynamicLinks())
}
)
@@ -81,7 +81,7 @@ pkgconfig <- function(opt = c("PKG_CXX_LIBS", "PKG_C_LIBS", "PKG_CXX_HL_LIBS", "
sprintf('-L%s -lhdf5_hl -lhdf5 %s',
patharch, winlibs)
}, {
- sprintf('"%s/libhdf5_hl.a" "%s/libhdf5.a"%s%s',
+ sprintf('-lhdf5_hl -lhdf5',
patharch, patharch, .getSzipLoc(patharch), .getDynamicLinks())
}
)
@@ -92,7 +92,7 @@ pkgconfig <- function(opt = c("PKG_CXX_LIBS", "PKG_C_LIBS", "PKG_CXX_HL_LIBS", "
sprintf('-L%s -lhdf5_hl_cpp -lhdf5_hl -lhdf5_cpp -lhdf5 %s',
patharch, winlibs)
}, {
- sprintf('"%s/libhdf5_hl_cpp.a" "%s/libhdf5_hl.a" "%s/libhdf5_cpp.a" "%s/libhdf5.a"%s%s',
+ sprintf('-lhdf5_hl_cpp -lhdf5_hl -lhdf5_cpp -lhdf5',
patharch, patharch, patharch, patharch, .getSzipLoc(patharch), .getDynamicLinks())
}
)
@@ -124,6 +124,7 @@ getHdf5Version <- function() {
#'
#' @keywords internal
.getDynamicLinks <- function() {
+ return("")
sysname <- Sys.info()['sysname']
if(sysname == "Windows") {
links <- "-lz"
diff --git a/src/Makevars.in b/src/Makevars.in
index addb6a0..590784a 100644
--- a/src/Makevars.in
+++ b/src/Makevars.in
@@ -18,7 +18,7 @@ USER_LIB_DIR = ${R_PACKAGE_DIR}/lib${R_ARCH}/
PKG_CPPFLAGS = -I${USER_INCLUDE_DIR} ${ZLIB_INCLUDE}
PKG_CFLAGS = ${ZLIB_LIB}
-PKG_LIBS = "${USER_LIB_DIR}libhdf5.a" @SZIP_LIB@ -lz
+PKG_LIBS = -lhdf5 -lsz
@@ -26,7 +26,7 @@ all: $(SHLIB)
$(SHLIB): Rhdf5lib.o
-Rhdf5lib.o: copy-hdf5 @COPY_SZIP@
+Rhdf5lib.o:
copy-szip: copy-hdf5
cp hdf5/libaec-1.0.4/build/szip/lib/libsz.a "${USER_LIB_DIR}"

View File

@@ -0,0 +1,15 @@
diff -ru -x '*~' Rserve_orig/src/Makevars.in Rserve/src/Makevars.in
--- Rserve_orig/src/Makevars.in 2013-08-22 06:09:33.000000000 +0900
+++ Rserve/src/Makevars.in 2014-11-09 21:36:31.184590320 +0900
@@ -12,8 +12,9 @@
$(CC) -DSTANDALONE_RSERVE -DRSERV_DEBUG -DNODAEMON -I. -Iinclude $(ALL_CPPFLAGS) $(ALL_CFLAGS) $(PKG_CPPFLAGS) $(PKG_CFLAGS) -o Rserve.dbg $(SERVER_SRC) $(ALL_LIBS) $(PKG_LIBS)
# merging to bin/Rserve works only if installed from sources, won't work for binary
- -./mergefat Rserve "$(R_HOME)/bin/Rserve"
- -./mergefat Rserve.dbg "$(R_HOME)/bin/Rserve.dbg"
+ mkdir $(out)/bin
+ -./mergefat Rserve "$(out)/bin/Rserve"
+ -./mergefat Rserve.dbg "$(out)/bin/Rserve.dbg"
client: config.h
cp config.h client/cxx/

View File

@@ -0,0 +1,47 @@
diff --git a/R/AFND_interface.R b/R/AFND_interface.R
index b62e8e0..0f22d85 100644
--- a/R/AFND_interface.R
+++ b/R/AFND_interface.R
@@ -244,9 +244,9 @@ check_population <- function(hla_population) {
#' @return list of valid countries, regions and ethnic origin
#' @keywords internal
get_valid_geographics <- function() {
- url <- "http://www.allelefrequencies.net/hla6006a.asp?"
- html_input <- getURL(url, read_method = "html")
-
+ # http://www.allelefrequencies.net/hla6006a.asp?
+ html_input <- xml2::read_html("nix-valid-geographics")
+
rvest_tables <- rvest::html_table(html_input, fill = TRUE)
# country
diff --git a/R/external_resources_input.R b/R/external_resources_input.R
index c4b1dc1..8fc5881 100644
--- a/R/external_resources_input.R
+++ b/R/external_resources_input.R
@@ -74,16 +74,17 @@ getURL <- function(URL, N.TRIES=2L,
# MHC I
# netmhcI_input_template is an internal variable containing list of valid
# NetMHCpan input alleles
-netmhcI_input_template <- getURL(
- URL="https://services.healthtech.dtu.dk/services/NetMHCpan-4.1/allele.list",
- read_method = "delim", delim = "\t",
- col_names = c("netmhc_input", "hla_chain_name", "HLA_gene"))
+netmhcI_input_template <- readr::read_delim(
+ # https://services.healthtech.dtu.dk/services/NetMHCpan-4.1/allele.list
+ "nix-NetMHCpan-4.1-allele-list",
+ delim = "\t",
+ skip = 0,
+ col_names = c("netmhc_input", "hla_chain_name", "HLA_gene")
+ )
# MHC II
-lines <- getURL(
- URL = paste0("https://services.healthtech.dtu.dk/services/",
- "NetMHCIIpan-4.0/alleles_name.list"),
- read_method = "lines")
+# https://services.healthtech.dtu.dk/services/NetMHCIIpan-4.0/alleles_name.list
+lines <- readr::read_lines("nix-NETMHCIIpan-4.0-alleles-name-list")
lines_rep <- stringr::str_replace_all(lines, "\t+|\\s\\s+", "\t")
netmhcII_input_template <- suppressWarnings(
suppressMessages(read.delim(textConnection(lines_rep), sep = "\t")))

View File

@@ -0,0 +1,47 @@
diff --git a/src/Makevars b/src/Makevars
index 713b44c..704ac17 100644
--- a/src/Makevars
+++ b/src/Makevars
@@ -1,5 +1,5 @@
RHDF5_LIBS = $(shell "$(R_HOME)/bin${R_ARCH_BIN}/Rscript" -e 'Rhdf5lib::pkgconfig("PKG_C_LIBS")')
-PKG_LIBS = $(RHDF5_LIBS)
+PKG_LIBS = $(RHDF5_LIBS) -lhdf5
#PKG_CFLAGS = -Wall
diff --git a/src/h5testLock.c b/src/h5testLock.c
index b326444..5d58b4a 100644
--- a/src/h5testLock.c
+++ b/src/h5testLock.c
@@ -8,16 +8,16 @@ SEXP _h5fileLock(SEXP _file_name) {
int lk = -1;
/* create the temporary file */
- fd = HDopen(file_name, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ fd = open(file_name, O_RDWR | O_CREAT | O_TRUNC, 0666);
/* try to lock file */
- lk = HDflock(fd, LOCK_EX | LOCK_NB);
+ lk = flock(fd, LOCK_EX | LOCK_NB);
/* unlock so we can remove */
- HDflock(fd, LOCK_UN);
+ flock(fd, LOCK_UN);
/* close */
- HDclose(fd);
+ close(fd);
/* return value of lock attempt */
PROTECT(Rval = allocVector(INTSXP, 1));
diff --git a/src/h5testLock.h b/src/h5testLock.h
index 2c1c5e4..25914ff 100644
--- a/src/h5testLock.h
+++ b/src/h5testLock.h
@@ -1,5 +1,5 @@
#include <fcntl.h>
+#include <unistd.h>
#include "myhdf5.h"
-#include <H5private.h>
SEXP _h5fileLock();

View File

@@ -0,0 +1,12 @@
diff --git a/src/Makevars.in b/src/Makevars.in
--- a/src/Makevars.in
+++ b/src/Makevars.in
@@ -15,7 +15,7 @@ RANLIB := @RANLIB@
MAKE := @MAKE@
AR := @AR@
-PKG_CPPFLAGS := @CPPFLAGS@ -I"@RHDF5_INCLUDE@"
+PKG_CPPFLAGS := @CPPFLAGS@
PKG_LDFLAGS := @LDFLAGS@
export
all: copying $(SHLIB)

View File

@@ -0,0 +1,10 @@
diff --git a/src/Makevars b/src/Makevars
index 6e08950..e66fbbd 100644
--- a/src/Makevars
+++ b/src/Makevars
@@ -1,5 +1 @@
CXX_STD=CXX11
-PKG_LIBS=`"$(R_HOME)/bin/Rscript" -e "RcppThread::LdFlags()"`
-strippedLib: $(SHLIB)
- if test -e "/usr/bin/strip" & test -e "/bin/uname" & [[ `uname` == "Linux" ]] ; then /usr/bin/strip --strip-debug $(SHLIB); fi
-.phony: strippedLib

View File

@@ -0,0 +1,21 @@
# Run
#
# nix-build test-evaluation.nix --dry-run
#
# to test whether the R package set evaluates properly.
let
config = {
allowBroken = true;
allowUnfree = true;
};
inherit (import ../../.. { inherit config; }) pkgs;
rWrapper = pkgs.rWrapper.override {
packages = pkgs.lib.filter pkgs.lib.isDerivation (pkgs.lib.attrValues pkgs.rPackages);
};
in
rWrapper

View File

@@ -0,0 +1,47 @@
{
lib,
runCommand,
R,
radian,
makeWrapper,
recommendedPackages,
packages,
wrapR ? false,
}:
runCommand (radian.name + "-wrapper")
{
preferLocalBuild = true;
allowSubstitutes = false;
buildInputs = [
R
radian
]
++ recommendedPackages
++ packages;
nativeBuildInputs = [ makeWrapper ];
passthru = { inherit recommendedPackages; };
meta = radian.meta // {
# To prevent builds on hydra
hydraPlatforms = [ ];
# prefer wrapper over the package
priority = (radian.meta.priority or lib.meta.defaultPriority) - 1;
};
}
(
''
makeWrapper "${radian}/bin/radian" "$out/bin/radian" \
--prefix "R_LIBS_SITE" ":" "$R_LIBS_SITE"
''
+ lib.optionalString wrapR ''
cd ${R}/bin
for exe in *; do
makeWrapper "${R}/bin/$exe" "$out/bin/$exe" \
--prefix "R_LIBS_SITE" ":" "$R_LIBS_SITE"
done
''
)

View File

@@ -0,0 +1,69 @@
{
lib,
stdenv,
runCommand,
R,
rstudio,
makeWrapper,
recommendedPackages,
packages,
fontconfig,
}:
runCommand (rstudio.name + "-wrapper")
{
preferLocalBuild = true;
allowSubstitutes = false;
nativeBuildInputs = [ makeWrapper ];
dontWrapQtApps = true;
buildInputs = [
R
rstudio
]
++ recommendedPackages
++ packages;
# rWrapper points R to a specific set of packages by using a wrapper
# (as in https://nixos.org/nixpkgs/manual/#r-packages) which sets
# R_LIBS_SITE. Ordinarily, it would be possible to make RStudio use
# this same set of packages by simply overriding its version of R
# with the wrapped one, however, RStudio internally overrides
# R_LIBS_SITE. The below works around this by turning R_LIBS_SITE
# into an R file (fixLibsR) which achieves the same effect, then
# uses R_PROFILE_USER to load this code at startup in RStudio.
fixLibsR = "fix_libs.R";
}
(
''
mkdir -p $out
echo "# Autogenerated by wrapper-rstudio.nix from R_LIBS_SITE" > $out/$fixLibsR
echo -n ".libPaths(c(.libPaths(), \"" >> $out/$fixLibsR
echo -n $R_LIBS_SITE | sed -e 's/:/", "/g' >> $out/$fixLibsR
echo -n "\"))" >> $out/$fixLibsR
echo >> $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
''
${lib.optionalString stdenv.hostPlatform.isLinux ''
# symlink files from unwrapped rstudio so that the desktop file and the icons
# are also installed when using the wrapped version
# TODO: figure out how to handle darwin .app structures
ln -s ${rstudio}/share $out
''}
makeWrapper ${rstudio}/bin/rstudio $out/bin/rstudio \
--set R_PROFILE_USER $out/$fixLibsR
''
)
)

View File

@@ -0,0 +1,38 @@
{
lib,
symlinkJoin,
R,
makeWrapper,
recommendedPackages,
packages,
}:
symlinkJoin {
name = R.name + "-wrapper";
preferLocalBuild = true;
allowSubstitutes = false;
buildInputs = [ R ] ++ recommendedPackages ++ packages;
paths = [ R ];
nativeBuildInputs = [ makeWrapper ];
postBuild = ''
cd ${R}/bin
for exe in *; do
rm "$out/bin/$exe"
makeWrapper "${R}/bin/$exe" "$out/bin/$exe" \
--prefix "R_LIBS_SITE" ":" "$R_LIBS_SITE"
done
'';
# Make the list of recommended R packages accessible to other packages such as rpy2
passthru = { inherit recommendedPackages; };
meta = R.meta // {
# To prevent builds on hydra
hydraPlatforms = [ ];
# prefer wrapper over the package
priority = (R.meta.priority or lib.meta.defaultPriority) - 1;
};
}