Created
December 2, 2025 17:07
-
-
Save felixbd/87eec2ef55c9e990747a3efdeb0862a4 to your computer and use it in GitHub Desktop.
nix shell (dev env) for python3 and R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { pkgs ? import <nixpkgs> {} }: | |
| let | |
| r_pkgs = with pkgs.rPackages; [ | |
| # ---- RMarkdown-related packages ---- | |
| knitr # Core package for dynamic report generation in R; integrates code, output, and text. | |
| rmarkdown # Converts R Markdown files into HTML, PDF, or Word reports; supports reproducible documents. | |
| tidyverse # Collection of packages for data science (ggplot2, dplyr, tidyr, readr, etc.). | |
| viridis # Color palettes optimized for perceptual uniformity and colorblind-friendliness. | |
| # ---- RStudio-related packages ---- | |
| servr # Local web server for R; useful for previewing documents and interactive apps. | |
| pbdZMQ # Interface to ZeroMQ messaging; enables communication between R and other processes (used by RStudio/IRkernel). | |
| # ---- Data Manipulation & Visualization ---- | |
| dplyr # Data manipulation (filtering, summarizing, joining, etc.) using a clear syntax. | |
| ggplot2 # Grammar of graphics-based visualization for highly customizable plots. | |
| corrplot # Visualization of correlation and covariance matrices. | |
| patchwork | |
| randomForest | |
| ]; | |
| in | |
| # with tinypkgs; # Put tinypkgs's attributes in the current scope. | |
| # with pkgs; # Same for pkgs. | |
| pkgs.mkShell { | |
| name = "R-and-python3-env"; | |
| buildInputs = [ # with pkgs; [ | |
| pkgs.texlive.combined.scheme-full | |
| pkgs.pandoc | |
| # === python stuff === | |
| (pkgs.python313.withPackages(ps: with ps; [ | |
| jupyter ipython | |
| matplotlib | |
| seaborn | |
| numpy | |
| pandas | |
| polars | |
| ])) | |
| # === end python stuff === | |
| # === R stuff === | |
| (pkgs.rWrapper.override { | |
| packages = r_pkgs; | |
| }) | |
| (pkgs.rstudioWrapper.override { | |
| packages = r_pkgs; | |
| }) | |
| # == end R stuff === | |
| ]; | |
| shellHook = '' | |
| echo "environment activated" | |
| echo "" | |
| echo "System and package versions for reproducibility:" | |
| echo " Nixpkgs revision: ${pkgs.lib.version}" | |
| echo " R version: $(R --version | head -n 1)" | |
| echo " Installed R packages:" | |
| Rscript -e 'sessionInfo()' | |
| ''; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment