diff --git a/pkgs/build-support/fetchurl/mirrors.nix b/pkgs/build-support/fetchurl/mirrors.nix index 14b4d6fc9a27..9a3cdd5c77d2 100644 --- a/pkgs/build-support/fetchurl/mirrors.nix +++ b/pkgs/build-support/fetchurl/mirrors.nix @@ -300,120 +300,15 @@ rec { # The commented-out ones don't seem to allow direct package downloads; # they serve error messages that result in hash mismatches instead. bioc = [ - # http://bioc.ism.ac.jp/3.2/bioc/ - # http://bioc.openanalytics.eu/3.2/bioc/ - # http://bioconductor.fmrp.usp.br/3.2/bioc/ - # http://mirror.aarnet.edu.au/pub/bioconductor/3.2/bioc/ - # http://watson.nci.nih.gov/bioc_mirror/3.2/bioc/ - http://bioconductor.jp/packages/3.2/bioc/ - http://bioconductor.statistik.tu-dortmund.de/packages/3.2/bioc/ - http://mirrors.ebi.ac.uk/bioconductor/packages/3.2/bioc/ - http://mirrors.ustc.edu.cn/bioc/3.2/bioc/ - ]; - - # CRAN mirrors (from http://cran.r-project.org/mirrors.html) - cran = [ - http://cran.r-project.org/ - http://cran.rstudio.com/ - http://cran.usthb.dz/ - http://mirror.fcaglp.unlp.edu.ar/CRAN/ - http://cran.csiro.au/ - http://cran.ms.unimelb.edu.au/ - http://cran.at.r-project.org/ - http://www.freestatistics.org/cran/ - http://nbcgib.uesc.br/mirrors/cran/ - http://cran-r.c3sl.ufpr.br/ - http://cran.fiocruz.br/ - http://www.vps.fmvz.usp.br/CRAN/ - http://brieger.esalq.usp.br/CRAN/ - http://cran.stat.sfu.ca/ - http://mirror.its.dal.ca/cran/ - http://cran.utstat.utoronto.ca/ - http://cran.skazkaforyou.com/ - http://cran.parentingamerica.com/ - http://dirichlet.mat.puc.cl/ - http://ftp.ctex.org/mirrors/CRAN/ - http://mirror.bjtu.edu.cn/cran - http://mirrors.ustc.edu.cn/CRAN/ - http://mirrors.xmu.edu.cn/CRAN/ - http://www.laqee.unal.edu.co/CRAN/ - http://www.icesi.edu.co/CRAN/ - http://mirrors.nic.cz/R/ - http://mirrors.dotsrc.org/cran/ - http://cran.espol.edu.ec/ - http://cran.salud.gob.sv/ - http://ftp.eenet.ee/pub/cran/ - http://cran.univ-lyon1.fr/ - http://mirror.ibcp.fr/pub/CRAN/ - http://ftp.igh.cnrs.fr/pub/CRAN/ - http://cran.irsn.fr/ - http://cran.univ-paris1.fr/ - http://cran.cardse.net/ - http://mirrors.softliste.de/cran/ - http://ftp5.gwdg.de/pub/misc/cran/ - http://cran.sciserv.eu/ - http://cran.uni-muenster.de/ - http://cran.cc.uoc.gr/mirrors/CRAN/ - http://cran.rapporter.net/ - http://cran.hafro.is/ - http://ftp.iitm.ac.in/cran/ - http://cran.repo.bppt.go.id/ - http://cran.um.ac.ir/ - http://ftp.heanet.ie/mirrors/cran.r-project.org/ - http://cran.mirror.garr.it/mirrors/CRAN/ - http://cran.stat.unipd.it/ - http://dssm.unipa.it/CRAN/ - http://cran.ism.ac.jp/ - http://cran.md.tsukuba.ac.jp/ - http://cran.nexr.com/ - http://healthstat.snu.ac.kr/CRAN/ - http://cran.biodisk.org/ - http://rmirror.lau.edu.lb/ - http://cran.itam.mx/ - http://www.est.colpos.mx/R-mirror/ - http://cran.xl-mirror.nl/ - http://cran-mirror.cs.uu.nl/ - http://cran.stat.auckland.ac.nz/ - http://cran.uib.no/ - http://cran.stat.upd.edu.ph/ - http://r.meteo.uni.wroc.pl/ - http://cran.dcc.fc.up.pt/ - http://cran.gis-lab.info/ - http://cran.stat.nus.edu.sg/ - http://cran.fyxm.net/ - http://r.adu.org.za/ - http://cran.mirror.ac.za/ - http://ftp.cixug.es/CRAN/ - http://cran.es.r-project.org/ - http://ftp.sunet.se/pub/lang/CRAN/ - http://stat.ethz.ch/CRAN/ - http://ftp.yzu.edu.tw/CRAN/ - http://cran.csie.ntu.edu.tw/ - http://mirrors.psu.ac.th/pub/cran/ - http://cran.pau.edu.tr/ - http://www.stats.bris.ac.uk/R/ - http://mirrors.ebi.ac.uk/CRAN/ - http://cran.ma.imperial.ac.uk/ - http://mirror.mdx.ac.uk/R/ - http://star-www.st-andrews.ac.uk/cran/ - http://cran.cnr.berkeley.edu/ - http://cran.stat.ucla.edu/ - http://streaming.stat.iastate.edu/CRAN/ - http://ftp.ussg.iu.edu/CRAN/ - http://rweb.quant.ku.edu/cran/ - http://watson.nci.nih.gov/cran_mirror/ - http://cran.mtu.edu/ - http://cran.wustl.edu/ - http://cran.case.edu/ - http://ftp.osuosl.org/pub/cran/ - http://lib.stat.cmu.edu/R/CRAN/ - http://cran.mirrors.hoobly.com/ - http://mirrors.nics.utk.edu/cran/ - http://cran.revolutionanalytics.com/ - http://cran.fhcrc.org/ - http://cran.cs.wwu.edu/ - http://camoruco.ing.uc.edu.ve/cran/ - http://cran.vinastat.com/ + # http://bioc.ism.ac.jp/ + # http://bioc.openanalytics.eu/ + # http://bioconductor.fmrp.usp.br/ + # http://mirror.aarnet.edu.au/pub/bioconductor/ + # http://watson.nci.nih.gov/bioc_mirror/ + http://bioconductor.jp/packages/ + http://bioconductor.statistik.tu-dortmund.de/packages/ + http://mirrors.ebi.ac.uk/bioconductor/packages/ + http://mirrors.ustc.edu.cn/bioc/ ]; # Hackage mirrors diff --git a/pkgs/development/r-modules/default.nix b/pkgs/development/r-modules/default.nix index 84ae091ee11e..0d30dc4c6b81 100644 --- a/pkgs/development/r-modules/default.nix +++ b/pkgs/development/r-modules/default.nix @@ -11,7 +11,10 @@ let # # some packages, e.g. cncaGUI, require X running while installation, # so that we use xvfb-run if requireX is true. - mkDerive = {mkHomepage, mkUrls}: lib.makeOverridable ({ + mkDerive = {mkHomepage, mkUrls}: args: + # XXX: not ideal ("2.2" would match "2.22") but sufficient + assert (!(args ? rVersion) || lib.hasPrefix args.rVersion (lib.getVersion R)); + lib.makeOverridable ({ name, version, sha256, depends ? [], doCheck ? true, @@ -22,12 +25,12 @@ let name = "${name}-${version}"; src = fetchurl { inherit sha256; - urls = mkUrls { inherit name version; }; + urls = mkUrls (args // { inherit name version; }); }; inherit doCheck requireX; propagatedBuildInputs = depends; nativeBuildInputs = depends; - meta.homepage = mkHomepage name; + meta.homepage = mkHomepage (args // { inherit name; }); meta.platforms = R.meta.platforms; meta.hydraPlatforms = hydraPlatforms; meta.broken = broken; @@ -37,18 +40,15 @@ let # from the name, version, sha256, and optional per-package arguments above # deriveBioc = mkDerive { - mkHomepage = name: "http://cran.r-project.org/web/packages/${name}/"; - mkUrls = {name, version}: [ "mirror://bioc/src/contrib/${name}_${version}.tar.gz" ]; + mkHomepage = {name, rVersion}: "https://bioconductor.org/packages/${rVersion}/bioc/html/${name}.html"; + mkUrls = {name, version, rVersion}: [ "mirror://bioc/${rVersion}/bioc/src/contrib/${name}_${version}.tar.gz" ]; }; deriveCran = mkDerive { - mkHomepage = name: "http://bioconductor.org/packages/release/bioc/html/${name}.html"; - mkUrls = {name, version}: [ - "mirror://cran/src/contrib/${name}_${version}.tar.gz" - "mirror://cran/src/contrib/00Archive/${name}/${name}_${version}.tar.gz" - ]; + mkHomepage = {name, snapshot}: "http://mran.revolutionanalytics.com/snapshot/${snapshot}/web/packages/${name}/"; + mkUrls = {name, version, snapshot}: [ "http://mran.revolutionanalytics.com/snapshot/${snapshot}/src/contrib/${name}_${version}.tar.gz" ]; }; deriveIRkernel = mkDerive { - mkHomepage = name: "http://irkernel.github.io/"; + mkHomepage = {name}: "https://irkernel.github.io/"; mkUrls = {name, version}: [ "http://irkernel.github.io/src/contrib/${name}_${version}.tar.gz" ]; }; diff --git a/pkgs/development/r-modules/generate-r-packages.R b/pkgs/development/r-modules/generate-r-packages.R index 4c5654184509..d45401b957de 100755 --- a/pkgs/development/r-modules/generate-r-packages.R +++ b/pkgs/development/r-modules/generate-r-packages.R @@ -7,14 +7,16 @@ mirrorType <- commandArgs(trailingOnly=TRUE)[1] stopifnot(mirrorType %in% c("bioc","cran", "irkernel")) packagesFile <- paste(mirrorType, 'packages.nix', sep='-') -readFormatted <- as.data.table(read.table(skip=6, sep='"', text=head(readLines(packagesFile), -1))) +readFormatted <- as.data.table(read.table(skip=8, sep='"', text=head(readLines(packagesFile), -1))) +rVersion <- paste(R.Version()$major, strsplit(R.Version()$minor, ".", fixed=TRUE)[[1]][1], sep=".") +snapshotDate <- Sys.Date() -mirrorUrls <- list( bioc="http://bioconductor.statistik.tu-dortmund.de/packages/3.2/bioc/src/contrib/" - , cran="http://cran.r-project.org/src/contrib/" - , irkernel="http://irkernel.github.io/src/contrib/" +mirrorUrls <- list( bioc=paste0("https://bioconductor.statistik.tu-dortmund.de/packages/", rVersion, "/bioc/src/contrib/") + , cran=paste0("https://mran.revolutionanalytics.com/snapshot/", snapshotDate, "/src/contrib/") + , irkernel="https://irkernel.github.io/src/contrib/" ) mirrorUrl <- mirrorUrls[mirrorType][[1]] -knownPackages <- lapply(mirrorUrls, function(url) as.data.table(available.packages(url, filters=c("R_version", "OS_type", "duplicates")))) +knownPackages <- lapply(mirrorUrls, function(url) as.data.table(available.packages(url, filters=c("R_version", "OS_type", "duplicates")), method="libcurl")) pkgs <- knownPackages[mirrorType][[1]] setkey(pkgs, Package) knownPackages <- c(unique(do.call("rbind", knownPackages)$Package)) @@ -38,12 +40,12 @@ formatPackage <- function(name, version, sha256, depends, imports, linkingTo) { depends <- sapply(depends, gsub, pattern=".", replacement="_", fixed=TRUE) depends <- depends[depends %in% knownPackages] depends <- paste(sort(unique(depends)), collapse=" ") - paste0(attr, " = derive { name=\"", name, "\"; version=\"", version, "\"; sha256=\"", sha256, "\"; depends=[", depends, "]; };") + paste0(" ", attr, " = derive2 { name=\"", name, "\"; version=\"", version, "\"; sha256=\"", sha256, "\"; depends=[", depends, "]; };") } clusterExport(cl, c("nixPrefetch","readFormatted", "mirrorUrl", "knownPackages")) -pkgs <- as.data.table(available.packages(mirrorUrl, filters=c("R_version", "OS_type", "duplicates"))) +pkgs <- as.data.table(available.packages(mirrorUrl, filters=c("R_version", "OS_type", "duplicates"), method="libcurl")) pkgs <- pkgs[order(Package)] pkgs$sha256 <- parApply(cl, pkgs, 1, function(p) nixPrefetch(p[1], p[2])) @@ -54,8 +56,14 @@ cat("# Execute the following command to update the file.\n") cat("#\n") cat(paste("# Rscript generate-r-packages.R", mirrorType, ">new && mv new", packagesFile)) cat("\n\n") -cat("{ self, derive }: with self; {\n") -cat(paste(nix, collapse="\n"), "\n") +cat("{ self, derive }:\n") +cat("let derive2 = derive ") +if (mirrorType == "bioc") { cat("{ rVersion = \"", rVersion, "\"; }", sep="") +} else if (mirrorType == "cran") { cat("{ snapshot = \"", paste(snapshotDate), "\"; }", sep="") +} else if (mirrorType == "irkernel") { cat("{}") } +cat(";\n") +cat("in with self; {\n") +cat(paste(nix, collapse="\n"), "\n", sep="") cat("}\n") stopCluster(cl) diff --git a/pkgs/development/r-modules/generate-shell.nix b/pkgs/development/r-modules/generate-shell.nix new file mode 100644 index 000000000000..43c97e009c7e --- /dev/null +++ b/pkgs/development/r-modules/generate-shell.nix @@ -0,0 +1,16 @@ +with import {}; + +stdenv.mkDerivation { + name = "generate-r-packages-shell"; + + buildCommand = "exit 1"; + + nativeBuildInputs = [ + (rWrapper.override { + packages = with rPackages; [ + data_table + parallel + ]; + }) + ]; +}