`nix profile install` for `rWrapper.override(...)`

I want an R interpreter installed with a set of packages that is accessible globally on my system.

  • I know I can install R globally via nix profile install nixpkgs#R nixpkgs#rPackages.ggplot2, but this doesn’t have any dependencies like ggplot2 accessible from the R shell
  • I know I can get a nix-shell of this using a command like what is shown in the nix docs:
nix-shell --packages 'rWrapper.override{packages = [ rPackages.ggplot2 ];}'
  • I know I can nix develop into an environment like this using the following flake.nix file:
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
  };

  outputs =
    {
      self,
      nixpkgs,
    }:

    let
      system = "aarch64-darwin";
      pkgs = import nixpkgs { inherit system; };
    in
    {
      default = pkgs.mkShell {
        buildInputs = with pkgs; [
          (rWrapper.override {
            packages = with pkgs.rPackages; [
              ggplot2
            ];
          })
        ];
      };
    };
}

→ now how do I install R globally with nix profile install to get this kind of install to live globally on my system (under some profile)?

1 Like

Perhaps the NixOS option environment.systemPackages.

Oh, this is nix-darwin? Well it has an equivalent option. May be the same attrpath.

oh, I haven’t installed nix-darwin, I just have nix for macOS. if I feel up for it this weekend I might try it.

is there a way to do this without nix-darwin?