From f47b72ed738e7f14a34514ae2c0509e0367804d9 Mon Sep 17 00:00:00 2001 From: Filipe da Silva Santos Date: Wed, 14 Feb 2024 00:11:50 -0300 Subject: [PATCH] Add R environment Contains minimal knitr dependencies for generating reports --- README.md | 11 +++++++++++ flake.nix | 5 +++++ r/.envrc | 1 + r/flake.lock | 27 +++++++++++++++++++++++++++ r/flake.nix | 31 +++++++++++++++++++++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 r/.envrc create mode 100644 r/flake.lock create mode 100644 r/flake.nix diff --git a/README.md b/README.md index 35a0d90..6c25ea9 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ Once your preferred template has been initialized, you can use the provided shel | [Protobuf] | [`protobuf`](./protobuf/) | | [Pulumi] | [`pulumi`](./pulumi/) | | [Purescript] | [`purescript`](./purescript/) | +| [R] | [`r`](./r/) | | [Ruby] | [`ruby`](./ruby/) | | [Rust] | [`rust`](./rust/) | | [Scala] | [`scala`](./scala/) | @@ -223,6 +224,12 @@ The sections below list what each template includes. In all cases, you're free t - [pip] 23.0.1 - [Virtualenv] 20.19.0 +### [`r`](./r/) + +- [R] 4.3.1 +- [rmarkdown] 2.22 +- [knitr] 1.43 ([pandoc] and [texlive]) + ### [`ruby`](./ruby/) - [Ruby] 3.2.2, plus the standard Ruby tools (`bundle`, `gem`, etc.) @@ -300,6 +307,7 @@ All of the templates have only the root [flake](./flake.nix) as a flake input. T [iex]: https://hexdocs.pm/iex/IEx.html [java]: https://java.com [jq]: https://jqlang.github.io/jq +[knitr]: https://yihui.org/knitr/ [kotlin]: https://kotlinlang.org [latex]: https://www.latex-project.org/ [leiningen]: https://leiningen.org @@ -328,6 +336,7 @@ All of the templates have only the root [flake](./flake.nix) as a flake input. T [odoc]: https://github.com/ocaml/odoc [omnisharp-roslyn]: https://github.com/OmniSharp/omnisharp-roslyn [opa]: https://openpolicyagent.org +[pandoc]: https://pandoc.org/ [packer]: https://packer.io [pip]: https://pypi.org/project/pip [phoenix]: https://phoenixframework.org @@ -339,7 +348,9 @@ All of the templates have only the root [flake](./flake.nix) as a flake input. T [purescript-language-server]: https://github.com/nwolverson/purescript-language-server [purs-tidy]: https://github.com/natefaubion/purescript-tidy [python]: https://python.org +[r]: https://www.r-project.org/ [release]: https://github.com/NixOS/nixpkgs/releases/tag/22.11 +[rmarkdown]: https://rmarkdown.rstudio.com/ [ruby]: https://ruby-lang.org [rust]: https://rust-lang.org [rust-analyzer]: https://rust-analyzer.github.io diff --git a/flake.nix b/flake.nix index 100df82..2a0eaa5 100644 --- a/flake.nix +++ b/flake.nix @@ -176,6 +176,11 @@ description = "Python development environment"; }; + r = { + path = ./r; + description = "R development environment"; + }; + ruby = { path = ./ruby; description = "Ruby development environment"; diff --git a/r/.envrc b/r/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/r/.envrc @@ -0,0 +1 @@ +use flake diff --git a/r/flake.lock b/r/flake.lock new file mode 100644 index 0000000..0f56f8b --- /dev/null +++ b/r/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1689261696, + "narHash": "sha256-LzfUtFs9MQRvIoQ3MfgSuipBVMXslMPH/vZ+nM40LkA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "df1eee2aa65052a18121ed4971081576b25d6b5c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/r/flake.nix b/r/flake.nix new file mode 100644 index 0000000..da334ef --- /dev/null +++ b/r/flake.nix @@ -0,0 +1,31 @@ +{ + description = "A Nix-flake-based R development environment"; + + inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz"; + + outputs = { self, nixpkgs }: + let + overlays = [ + (final: prev: rec { + rEnv = prev.rWrapper.override { + packages = with prev.rPackages; [ knitr ]; + }; + }) + ]; + supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f { + pkgs = import nixpkgs { inherit overlays system; }; + }); + in + { + devShells = forEachSupportedSystem ({ pkgs }: { + default = pkgs.mkShell { + packages = with pkgs; + [ rEnv + pandoc + texlive.combined.scheme-full + ]; + }; + }); + }; +}