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

Small edits 2024-02-02 #130

Merged
merged 5 commits into from
Feb 2, 2024
Merged
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
113 changes: 65 additions & 48 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ output:

<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r, include = FALSE}
```{r, include=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
Expand All @@ -29,37 +29,46 @@ knitr::opts_chunk$set(

## Introduction

`{rix}` is an R package that leverages Nix, a powerful package manager focusing
on reproducible builds. With Nix, it is possible to create project-specific
environments that contain a project-specific version of R and R packages (as
well as other tools or languages, if needed). You can use `{rix}` and Nix to
replace `{renv}` and Docker with one single tool. Nix is an incredibly useful
piece of software for ensuring reproducibility of projects, in research or
otherwise, or for running web applications like Shiny apps or `{plumber}` APIs
in a controlled environment.

Nix has quite a high entry cost though, because Nix is a complex piece of
software that comes with its own programming language (also called Nix) whose
purpose is to solve a complex problem: installing software in a reproducible
manner, on any operating system or hardware.

`{rix}` provides functions to help you write Nix expressions (written in the Nix
language): these expressions can then be used by the Nix package manager to
build completely reproducible development environments. These environments can
be used for interactive data analysis or running pipelines in a CI/CD
environment. Environments built with Nix contain R and all the required packages
that you need for your project: there are currently more than 80.000 pieces of
software available through the Nix package manager, including the entirety of
CRAN and Bioconductor packages. It is also possible to install older releases of
packages, or install packages from GitHub.

The Nix package manager is extremely powerful: not only it handles all the
dependencies of any package extremely well, it is also possible with it to
reproduce environments containing old releases of software. It is thus possible
to build environments that contain R version 4.0.0 (for example) to run an old
project originally developed on that version of R.

As stated above, with Nix, it is essentially possible to replace `{renv}` and
`{rix}` is an R package that leverages [Nix](https://nixos.org/),
a powerful package manager focusing on reproducible builds. With Nix, it is
possible to create project-specific environments that contain a project-specific
version of R and R packages (as well as other tools or languages, if needed).
You can use `{rix}` and Nix to replace `{renv}` and Docker with one single tool.
Nix is an incredibly useful piece of software for ensuring reproducibility of
projects, in research or otherwise. For example, it allows you run web
applications like Shiny apps or `{plumber}` APIs in a controlled environment.

Nix has a fairly high entry cost though. Nix is a complex piece of software that
comes with its own programming language, which is also called Nix. Its purpose
is to solve a complex problem: defining instructions on how to build software
packages and manage configurations in a declarative way. This makes sure that
software gets installed in fully reproducible manner, on any operating system or
hardware.

`{rix}` provides functions to help you write and deploy Nix expressions (written
in the Nix language). These expressions will be the inputs for the Nix package
manager, to build sets of software packages and provide them in a reproducible
development environment. These environments can be used for interactive data
analysis, or reproduced when running pipelines in CI/CD systems. On the
[Nixpkgs collection](https://github.com/nixos/nixpkgs), there are currently more
than 80.000 pieces of software available through the Nix package manager.
Through {rix}, you can define and build isolated R environments through Nix
package manager with ease. Like this, environments contain R and all the
required packages that you need for your project. You can also add any other
software tool available. The Nix R ecosystem currently includes the entirety of
CRAN and Bioconductor packages. Like with any other programming language and
software, it is also possible to install older releases of R packages, or
install packages from GitHub at defined states.

The Nix package manager is extremely powerful. Not only does it handle all the
dependencies of any package extremely well in a deterministic manner, it is also
possible with it to reproduce environments containing old releases of software.
It is thus possible to build environments containing R version 4.0.0 (for
example) to run an old project that was originally developed on that version of
R.

As stated above, with Nix, it is essentially possible to replace
[`{renv}`](https://rstudio.github.io/renv/) and
Docker combined. If you need other tools or languages like Python or Julia, this
can also be done easily. Nix is available for Linux, macOS and Windows (via
WSL2) and `{rix}` comes with the following features:
Expand All @@ -68,18 +77,30 @@ WSL2) and `{rix}` comes with the following features:
- have several versions of R and R packages installed at the same time on the
same system;
- define complete development environments as code and use them anywhere;
- run single function in a different environment (potentially with a different R
version and R packages) for an interactive R session and get back the output
of that function using `with_nix()`;
- run single R functions (and objects in the call stack) in a different
environment (potentially with a different R version and R packages) for an
interactive R session, and get back the output of that function using
[`with_nix()`](https://b-rodrigues.github.io/rix/reference/with_nix.html);

`{rix}` does not require Nix to be installed on your system to generate
expressions. This means that you can generate expressions on a system on which
you cannot easily install software, and then use these expressions on the cloud
or on a CI/CD environment to build the project there.

Here is an example of how to define an environment "as code" using `rix()`:
If you have R installed, you can start straight away from your R session by
first installing `{rix}`:


```{r, eval=FALSE}
install.packages("rix", repos = c("https://b-rodrigues.r-universe.dev",
"https://cloud.r-project.org"))

library("rix")
```

```{r, eval=FALSE}
path_default_nix <- "."

```{r, eval = F}
rix(r_ver = "latest",
r_pkgs = c("dplyr", "ggplot2"),
system_pkgs = NULL,
Expand All @@ -98,6 +119,9 @@ the Nix package manager must be installed.

*If you are not familiar with Nix or `{rix}` skip to the next section.*

<details>

<summary>Click to expand</summary>
If you are already familiar with Nix and R, and simply want to get started as
quickly as possible, you can start by installing Nix using the installer from
[Determinate
Expand All @@ -110,16 +134,6 @@ curl --proto '=https' --tlsv1.2 -sSf \
sh -s -- install
```

If you have R installed, you can start straight away from your R session by first
installing `{rix}`:

```{r, eval=FALSE}
install.packages("rix", repos = c("https://b-rodrigues.r-universe.dev",
"https://cloud.r-project.org"))

library("rix")
```

You can check that everything works well by trying to build the Nix expression
that ships with `{rix}`. Nix expressions are typically saved into files with the
name `default.nix` or `shell.nix`. This expression installs the latest version
Expand Down Expand Up @@ -151,11 +165,14 @@ nix-shell --expr "$(curl -sl https://raw.githubusercontent.com/b-rodrigues/rix/m

You can then create new development environment definitions, build them, and
start using them.
</details>

## Getting started for new users

To get started with `{rix}` and Nix, you should read the following vignette
`vignette("a-getting-started")`. The vignettes are numbered to get you to learn
`vignette("a-getting-started")`
([online documentation](https://b-rodrigues.github.io/rix/articles/a-getting-started.html)).
The vignettes are numbered to get you to learn
how to use `{rix}` and Nix smoothly. There’s a lot of info, so take your time
reading the vignettes. Don’t hesitate to open an issue if something is not
clear.
Expand Down
126 changes: 71 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,63 +26,82 @@ rix](https://b-rodrigues.r-universe.dev/badges/rix?scale=1&color=pink&style=roun

## Introduction

`{rix}` is an R package that leverages Nix, a powerful package manager
focusing on reproducible builds. With Nix, it is possible to create
project-specific environments that contain a project-specific version of
R and R packages (as well as other tools or languages, if needed). You
can use `{rix}` and Nix to replace `{renv}` and Docker with one single
tool. Nix is an incredibly useful piece of software for ensuring
reproducibility of projects, in research or otherwise, or for running
web applications like Shiny apps or `{plumber}` APIs in a controlled
environment.

Nix has quite a high entry cost though, because Nix is a complex piece
of software that comes with its own programming language (also called
Nix) whose purpose is to solve a complex problem: installing software in
a reproducible manner, on any operating system or hardware.

`{rix}` provides functions to help you write Nix expressions (written in
the Nix language): these expressions can then be used by the Nix package
manager to build completely reproducible development environments. These
environments can be used for interactive data analysis or running
pipelines in a CI/CD environment. Environments built with Nix contain R
and all the required packages that you need for your project: there are
currently more than 80.000 pieces of software available through the Nix
package manager, including the entirety of CRAN and Bioconductor
packages. It is also possible to install older releases of packages, or
install packages from GitHub.

The Nix package manager is extremely powerful: not only it handles all
the dependencies of any package extremely well, it is also possible with
it to reproduce environments containing old releases of software. It is
thus possible to build environments that contain R version 4.0.0 (for
example) to run an old project originally developed on that version of
R.
`{rix}` is an R package that leverages [Nix](https://nixos.org/), a
powerful package manager focusing on reproducible builds. With Nix, it
is possible to create project-specific environments that contain a
project-specific version of R and R packages (as well as other tools or
languages, if needed). You can use `{rix}` and Nix to replace `{renv}`
and Docker with one single tool. Nix is an incredibly useful piece of
software for ensuring reproducibility of projects, in research or
otherwise. For example, it allows you run web applications like Shiny
apps or `{plumber}` APIs in a controlled environment.

Nix has a fairly high entry cost though. Nix is a complex piece of
software that comes with its own programming language, which is also
called Nix. Its purpose is to solve a complex problem: defining
instructions on how to build software packages and manage configurations
in a declarative way. This makes sure that software gets installed in
fully reproducible manner, on any operating system or hardware.

`{rix}` provides functions to help you write and deploy Nix expressions
(written in the Nix language). These expressions will be the inputs for
the Nix package manager, to build sets of software packages and provide
them in a reproducible development environment. These environments can
be used for interactive data analysis, or reproduced when running
pipelines in CI/CD systems. On the [Nixpkgs
collection](https://github.com/nixos/nixpkgs), there are currently more
than 80.000 pieces of software available through the Nix package
manager. Through {rix}, you can define and build isolated R environments
through Nix package manager with ease. Like this, environments contain R
and all the required packages that you need for your project. You can
also add any other software tool available. The Nix R ecosystem
currently includes the entirety of CRAN and Bioconductor packages. Like
with any other programming language and software, it is also possible to
install older releases of R packages, or install packages from GitHub at
defined states.

The Nix package manager is extremely powerful. Not only does it handle
all the dependencies of any package extremely well in a deterministic
manner, it is also possible with it to reproduce environments containing
old releases of software. It is thus possible to build environments
containing R version 4.0.0 (for example) to run an old project that was
originally developed on that version of R.

As stated above, with Nix, it is essentially possible to replace
`{renv}` and Docker combined. If you need other tools or languages like
Python or Julia, this can also be done easily. Nix is available for
Linux, macOS and Windows (via WSL2) and `{rix}` comes with the following
features:
[`{renv}`](https://rstudio.github.io/renv/) and Docker combined. If you
need other tools or languages like Python or Julia, this can also be
done easily. Nix is available for Linux, macOS and Windows (via WSL2)
and `{rix}` comes with the following features:

- install any version of R and R packages for specific projects;
- have several versions of R and R packages installed at the same time
on the same system;
- define complete development environments as code and use them
anywhere;
- run single function in a different environment (potentially with a
different R version and R packages) for an interactive R session and
get back the output of that function using `with_nix()`;
- run single R functions (and objects in the call stack) in a different
environment (potentially with a different R version and R packages)
for an interactive R session, and get back the output of that function
using
[`with_nix()`](https://b-rodrigues.github.io/rix/reference/with_nix.html);

`{rix}` does not require Nix to be installed on your system to generate
expressions. This means that you can generate expressions on a system on
which you cannot easily install software, and then use these expressions
on the cloud or on a CI/CD environment to build the project there.

Here is an example of how to define an environment “as code” using
`rix()`:
If you have R installed, you can start straight away from your R session
by first installing `{rix}`:

``` r
install.packages("rix", repos = c("https://b-rodrigues.r-universe.dev",
"https://cloud.r-project.org"))

library("rix")
```

``` r
path_default_nix <- "."

rix(r_ver = "latest",
r_pkgs = c("dplyr", "ggplot2"),
system_pkgs = NULL,
Expand All @@ -102,6 +121,11 @@ installed.

*If you are not familiar with Nix or `{rix}` skip to the next section.*

<details>
<summary>
Click to expand
</summary>

If you are already familiar with Nix and R, and simply want to get
started as quickly as possible, you can start by installing Nix using
the installer from [Determinate
Expand All @@ -114,16 +138,6 @@ curl --proto '=https' --tlsv1.2 -sSf \
sh -s -- install
```

If you have R installed, you can start straight away from your R session
by first installing `{rix}`:

``` r
install.packages("rix", repos = c("https://b-rodrigues.r-universe.dev",
"https://cloud.r-project.org"))

library("rix")
```

You can check that everything works well by trying to build the Nix
expression that ships with `{rix}`. Nix expressions are typically saved
into files with the name `default.nix` or `shell.nix`. This expression
Expand Down Expand Up @@ -154,14 +168,16 @@ installed, you can run a temporary R session with R using this command

You can then create new development environment definitions, build them,
and start using them.
</details>

## Getting started for new users

To get started with `{rix}` and Nix, you should read the following
vignette `vignette("a-getting-started")`. The vignettes are numbered to
get you to learn how to use `{rix}` and Nix smoothly. There’s a lot of
info, so take your time reading the vignettes. Don’t hesitate to open an
issue if something is not clear.
vignette `vignette("a-getting-started")` ([online
documentation](https://b-rodrigues.github.io/rix/articles/a-getting-started.html)).
The vignettes are numbered to get you to learn how to use `{rix}` and
Nix smoothly. There’s a lot of info, so take your time reading the
vignettes. Don’t hesitate to open an issue if something is not clear.

### Docker

Expand Down
4 changes: 2 additions & 2 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"@type": "SoftwareSourceCode",
"identifier": "rix",
"description": "Provides helper functions to create reproducible development environments using the Nix package manager.",
"name": "rix: Rix: Reproducible Environments With Nix",
"name": "rix: Rix: Reproducible Environments with Nix",
"codeRepository": "https://github.com/b-rodrigues/rix",
"issueTracker": "https://github.com/b-rodrigues/rix",
"license": "https://spdx.org/licenses/GPL-3.0",
Expand Down Expand Up @@ -139,7 +139,7 @@
},
"SystemRequirements": null
},
"fileSize": "194.622KB",
"fileSize": "1016.338KB",
"relatedLink": "https://b-rodrigues.github.io/rix/",
"releaseNotes": "https://github.com/b-rodrigues/rix/blob/master/NEWS.md",
"readme": "https://github.com/b-rodrigues/rix/blob/master/README.md",
Expand Down
8 changes: 5 additions & 3 deletions dev/0-dev_history.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,14 @@ rix(r_ver = "latest",
),
ide = "other",
project_path = "inst/extdata",
overwrite = TRUE)
overwrite = TRUE,
shell_hook = NULL)
```

Here's another, for testing purposes:

```{r, eval = FALSE}
rix(r_ver = "8ad5e8132c5dcf977e308e7bf5517cc6cc0bf7d8",
rix(r_ver = "94b122adfc90316feaea838f29aa3f2e3de2b203",
r_pkgs = c("dplyr", "AER@1.2-8"),
system_pkgs = c("quarto"),
git_pkgs = list(
Expand All @@ -287,7 +288,8 @@ rix(r_ver = "8ad5e8132c5dcf977e308e7bf5517cc6cc0bf7d8",
ide = "other",
project_path = "inst/extdata",
overwrite = TRUE,
print = TRUE)
print = TRUE,
shell_hook = NULL)
```


Expand Down
1 change: 0 additions & 1 deletion dev/a-getting_started.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,3 @@ installed on your system.

- If you’re running either Linux or Windows, read the Linux or Windows vignette: `vignette("b1-setting-up-and-using-rix-on-linux-and-windows")`
- If you’re running macOS, read the macOS vignette: `vignette("b2-setting-up-and-using-rix-on-macos")`

Loading
Loading