Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add contributor infos #28

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Depends:
Imports:
httr,
jsonlite,
sys,
utils
Suggests:
knitr,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
export(available_r)
export(find_rev)
export(get_current)
export(nix_build)
export(rix)
importFrom(httr,GET)
importFrom(httr,content)
Expand Down
24 changes: 24 additions & 0 deletions R/find_rev.R
Original file line number Diff line number Diff line change
Expand Up @@ -388,3 +388,27 @@ USE_RSTUDIO};

}


#' Invoke shell command `nix-build` from an R session
#' @param nix_file File path to the `default.nix` file. The default is
#' a `default.nix` file in the current working directory of the current R
#' session.
#' @param exec_mode Either `"blocking"` (default) or `"non-blocking`. This
#' will either block the R session while the `nix-build` shell command is
#' executed, or run `nix-build` in the background ("non-blocking").
#' @return integer of the process ID (PID) of `nix-build` shell command
#' launched.
#' @export
nix_build <- function(nix_file = file.path("default.nix"),
exec_mode = c("blocking", "non-blocking")) {
stopifnot(is.character(nix_file))
exec_mode <- match.arg(exec_mode)

proc <- switch(exec_mode,
"blocking" = sys::exec_wait("nix-build", nix_file),
"non-blocking" = sys::exec_background("nix-build", nix_file),
stop('invalid `exec_mode`. Either use "blocking" or "non-blocking"')
)

return(invisible(proc))
}
3 changes: 2 additions & 1 deletion dev/0-dev_history.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ fusen::fill_description(
Description = "Provides helper functions to create reproducible development environments using the Nix package manager.",
Version = "0.0.9",
`Authors@R` = c(
person("Bruno", "Rodrigues", email = "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-3211-3689"))
person("Bruno", "Rodrigues", email = "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-3211-3689")),
person("Philipp", "Baumann", email = "[email protected]", role = "ctb", comment = c(ORCID = "0000-0002-3194-8975"))
)
)
)
Expand Down
29 changes: 29 additions & 0 deletions dev/build_envs.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -470,3 +470,32 @@ USE_RSTUDIO};
}

```

The function below is to invoke the shell command `nix-build` from a R
session.

```{r function-nix_build}
#' Invoke shell command `nix-build` from an R session
#' @param nix_file File path to the `default.nix` file. The default is
#' a `default.nix` file in the current working directory of the current R
#' session.
#' @param exec_mode Either `"blocking"` (default) or `"non-blocking`. This
#' will either block the R session while the `nix-build` shell command is
#' executed, or run `nix-build` in the background ("non-blocking").
#' @return integer of the process ID (PID) of `nix-build` shell command
#' launched.
#' @export
nix_build <- function(nix_file = file.path("default.nix"),
exec_mode = c("blocking", "non-blocking")) {
stopifnot(is.character(nix_file))
exec_mode <- match.arg(exec_mode)

proc <- switch(exec_mode,
"blocking" = sys::exec_wait("nix-build", nix_file),
"non-blocking" = sys::exec_background("nix-build", nix_file),
stop('invalid `exec_mode`. Either use "blocking" or "non-blocking"')
)

return(invisible(proc))
}
```
27 changes: 27 additions & 0 deletions man/nix_build.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.