From 3e6b47a0073ec41e6b89f25f5c407a51d7920f9f Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Mon, 3 Apr 2023 15:24:07 +1000 Subject: [PATCH] rPackages: switch to official CRAN mirrors --- pkgs/build-support/fetchurl/mirrors.nix | 5 +++++ pkgs/development/r-modules/default.nix | 7 ++++--- pkgs/development/r-modules/generate-r-packages.R | 14 +++++++------- pkgs/development/r-modules/generate-shell.nix | 1 - 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/pkgs/build-support/fetchurl/mirrors.nix b/pkgs/build-support/fetchurl/mirrors.nix index 3a765089bd2e..bd338473508a 100644 --- a/pkgs/build-support/fetchurl/mirrors.nix +++ b/pkgs/build-support/fetchurl/mirrors.nix @@ -43,6 +43,11 @@ "http://bioconductor.jp/packages/" ]; + # CRAN mirrors + cran = [ + "https://cran.r-project.org/src/contrib/" + ]; + # BitlBee mirrors, see https://www.bitlbee.org/main.php/mirrors.html bitlbee = [ "https://get.bitlbee.org/" diff --git a/pkgs/development/r-modules/default.nix b/pkgs/development/r-modules/default.nix index d85efc230546..aa7014cf4452 100644 --- a/pkgs/development/r-modules/default.nix +++ b/pkgs/development/r-modules/default.nix @@ -68,9 +68,10 @@ let hydraPlatforms = []; }; deriveCran = mkDerive { - mkHomepage = {name, snapshot, ...}: "https://cran.r-project.org/${snapshot}/web/packages/${name}/"; - mkUrls = {name, version, snapshot}: [ - "https://packagemanager.rstudio.com/cran/${snapshot}/src/contrib/${name}_${version}.tar.gz" + mkHomepage = {name, ...}: "https://cran.r-project.org/web/packages/${name}/"; + mkUrls = {name, version}: [ + "mirror://cran/${name}_${version}.tar.gz" + "mirror://cran/Archive/${name}/${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 0b01c09a278e..2395329a645a 100755 --- a/pkgs/development/r-modules/generate-r-packages.R +++ b/pkgs/development/r-modules/generate-r-packages.R @@ -1,6 +1,5 @@ #!/usr/bin/env Rscript library(data.table) -library(jsonlite) library(parallel) library(BiocManager) cl <- makeCluster(10) @@ -12,13 +11,11 @@ if ("release" %in% biocVersion$BiocStatus) { } else { biocVersion <- max(as.numeric(as.character(biocVersion$Bioc))) } -dates <- stream_in(url("https://packagemanager.rstudio.com/__api__/repos/2/transaction-dates"), verbose = FALSE) -snapshotDate <- as.Date(dates[nrow(dates), "alias"]) mirrorUrls <- list( bioc=paste0("http://bioconductor.statistik.tu-dortmund.de/packages/", biocVersion, "/bioc/src/contrib/") , "bioc-annotation"=paste0("http://bioconductor.statistik.tu-dortmund.de/packages/", biocVersion, "/data/annotation/src/contrib/") , "bioc-experiment"=paste0("http://bioconductor.statistik.tu-dortmund.de/packages/", biocVersion, "/data/experiment/src/contrib/") - , cran=paste0("https://packagemanager.rstudio.com/cran/", snapshotDate, "/src/contrib/") + , cran="https://cran.r-project.org/src/contrib/" ) mirrorType <- commandArgs(trailingOnly=TRUE)[1] @@ -44,6 +41,10 @@ nixPrefetch <- function(name, version) { 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, "'") @@ -74,9 +75,8 @@ formatPackage <- function(name, version, sha256, depends, imports, linkingTo) { paste0(" ", attr, " = derive2 { name=\"", name, "\"; version=\"", version, "\"; sha256=\"", sha256, "\"; depends=[", depends, "]; };") } -clusterExport(cl, c("nixPrefetch","readFormatted", "mirrorUrl", "knownPackages")) +clusterExport(cl, c("nixPrefetch","readFormatted", "mirrorUrl", "mirrorType", "knownPackages")) -pkgs <- as.data.table(available.packages(mirrorUrl, filters=c("R_version", "OS_type", "duplicates"), method="libcurl")) pkgs <- pkgs[order(Package)] write(paste("updating", mirrorType, "packages"), stderr()) @@ -102,7 +102,7 @@ cat(paste("# Rscript generate-r-packages.R", mirrorType, ">new && mv new", packa cat("\n\n") cat("{ self, derive }:\n") cat("let derive2 = derive ") -if (mirrorType == "cran") { cat("{ snapshot = \"", paste(snapshotDate), "\"; }", sep="") +if (mirrorType == "cran") { cat("{ }") } else if (mirrorType == "irkernel") { cat("{}") } else { cat("{ biocVersion = \"", biocVersion, "\"; }", sep="") } cat(";\n") diff --git a/pkgs/development/r-modules/generate-shell.nix b/pkgs/development/r-modules/generate-shell.nix index 0ab3d6fb557f..1c96cf05cb54 100644 --- a/pkgs/development/r-modules/generate-shell.nix +++ b/pkgs/development/r-modules/generate-shell.nix @@ -15,7 +15,6 @@ stdenv.mkDerivation { (rWrapper.override { packages = with rPackages; [ data_table - jsonlite parallel BiocManager ];