Skip to content

Commit

Permalink
fixed github packages with rstudio
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Rodrigues committed Jul 27, 2023
1 parent 65eaf9a commit b687014
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 16 deletions.
28 changes: 22 additions & 6 deletions R/find_rev.R
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ fetchgit <- function(git_pkg){
sri_hash <- sri_hash
}

sprintf('buildRPackage {
sprintf('(buildRPackage {
name = %s;
src = fetchgit {
url = \"%s\";
Expand Down Expand Up @@ -283,7 +283,7 @@ OTHER_PACKAGES other-pkgs = [OTHER_PKGS];
USE_RSTUDIO my-rstudio = rstudioWrapper.override {
USE_RSTUDIO packages = with rPackages; [
USE_RSTUDIO PACKAGE_LIST
USE_RSTUDIO GIT_PACKAGES
USE_RSTUDIO RSTUDIO_GITPKGS
USE_RSTUDIO ];
USE_RSTUDIO};
in
Expand All @@ -296,15 +296,31 @@ USE_RSTUDIO};
}"

nixFile <- gsub('RE_VERSION', find_rev(r_ver) , nixTemplate)
nixFile <- gsub('DATE', date(), nixFile)

nixFile <- gsub('USE_RSTUDIO',
ifelse(!is.null(ide) & ide == "rstudio", '', 'TO_DELETE'),
nixFile)

nixFile <- gsub('RSTUDIO_GITPKGS',
ifelse(!is.null(ide) & ide == "rstudio", 'GIT_PACKAGES', 'RSTUDIO_GITPKGS'),
nixFile)

r_packages <- gsub('\\.', '_', r_packages)
nixFile <- gsub('PACKAGE_LIST', r_packages, nixFile)

nixFile <- gsub('OTHER_PKGS', other_packages, nixFile)
nixFile <- gsub('OTHER_PACKAGES', ifelse(!is.null(other_pkgs), '', '#'), nixFile)
nixFile <- gsub('OTHER_PACKAGES',
ifelse(!is.null(other_pkgs), '', 'TO_DELETE'),
nixFile)

nixFile <- gsub('GIT_PACKAGES', ifelse(!is.null(git_pkgs),
fetchgits(git_pkgs),
'#'), nixFile)
nixFile <- gsub('DATE', date(), nixFile)
nixFile <- gsub('USE_RSTUDIO', ifelse(!is.null(ide) & ide == "rstudio", '', '#'), nixFile)
'TO_DELETE'), nixFile)

nixFile <- readLines(textConnection(nixFile))

nixFile <- grep('TO_DELETE', nixFile, invert = TRUE, value = TRUE)

if(!file.exists(path) | overwrite){
writeLines(nixFile, path)
Expand Down
28 changes: 22 additions & 6 deletions dev/build_envs.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ fetchgit <- function(git_pkg){
sri_hash <- sri_hash
}
sprintf('buildRPackage {
sprintf('(buildRPackage {
name = %s;
src = fetchgit {
url = \"%s\";
Expand Down Expand Up @@ -379,7 +379,7 @@ OTHER_PACKAGES other-pkgs = [OTHER_PKGS];
USE_RSTUDIO my-rstudio = rstudioWrapper.override {
USE_RSTUDIO packages = with rPackages; [
USE_RSTUDIO PACKAGE_LIST
USE_RSTUDIO GIT_PACKAGES
USE_RSTUDIO RSTUDIO_GITPKGS
USE_RSTUDIO ];
USE_RSTUDIO};
in
Expand All @@ -392,15 +392,31 @@ USE_RSTUDIO};
}"
nixFile <- gsub('RE_VERSION', find_rev(r_ver) , nixTemplate)
nixFile <- gsub('DATE', date(), nixFile)
nixFile <- gsub('USE_RSTUDIO',
ifelse(!is.null(ide) & ide == "rstudio", '', 'TO_DELETE'),
nixFile)
nixFile <- gsub('RSTUDIO_GITPKGS',
ifelse(!is.null(ide) & ide == "rstudio", 'GIT_PACKAGES', 'RSTUDIO_GITPKGS'),
nixFile)
r_packages <- gsub('\\.', '_', r_packages)
nixFile <- gsub('PACKAGE_LIST', r_packages, nixFile)
nixFile <- gsub('OTHER_PKGS', other_packages, nixFile)
nixFile <- gsub('OTHER_PACKAGES', ifelse(!is.null(other_pkgs), '', '#'), nixFile)
nixFile <- gsub('OTHER_PACKAGES',
ifelse(!is.null(other_pkgs), '', 'TO_DELETE'),
nixFile)
nixFile <- gsub('GIT_PACKAGES', ifelse(!is.null(git_pkgs),
fetchgits(git_pkgs),
'#'), nixFile)
nixFile <- gsub('DATE', date(), nixFile)
nixFile <- gsub('USE_RSTUDIO', ifelse(!is.null(ide) & ide == "rstudio", '', '#'), nixFile)
'TO_DELETE'), nixFile)
nixFile <- readLines(textConnection(nixFile))
nixFile <- grep('TO_DELETE', nixFile, invert = TRUE, value = TRUE)
if(!file.exists(path) | overwrite){
writeLines(nixFile, path)
Expand Down
4 changes: 2 additions & 2 deletions dev/building_envs_with_rix.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Basic usage:
path_default_nix <- tempdir()
rix(r_ver = "current",
rix(r_ver = "4.2.1",
r_pkgs = c("dplyr", "janitor"),
other_pkgs = c("quarto"),
git_pkgs = NULL,
Expand All @@ -28,7 +28,7 @@ cat(readLines(paste0(path_default_nix, "/default.nix")), sep = "\n")
Specifying a package on Github:

```{r}
rix(r_ver = "current",
rix(r_ver = "4.2.1",
r_pkgs = c("dplyr", "janitor"),
other_pkgs = c("quarto"),
git_pkgs = list(package_name = "housing",
Expand Down
4 changes: 2 additions & 2 deletions vignettes/building_envs_with_rix.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Basic usage:
path_default_nix <- tempdir()
rix(r_ver = "current",
rix(r_ver = "4.2.1",
r_pkgs = c("dplyr", "janitor"),
other_pkgs = c("quarto"),
git_pkgs = NULL,
Expand All @@ -45,7 +45,7 @@ Specifying a package on Github:


```{r}
rix(r_ver = "current",
rix(r_ver = "4.2.1",
r_pkgs = c("dplyr", "janitor"),
other_pkgs = c("quarto"),
git_pkgs = list(package_name = "housing",
Expand Down

0 comments on commit b687014

Please sign in to comment.