How to Install RStudio with Nix?

I’m fairly new to Nix and migrating from Homebrew. So far I’ve been able to install quite a bit using:

nix-env -q
nix-env -i
nix-channel --update
nix-env -u

However, I have not been able to successfully install RStudio. I’d appreciate help in understanding why I’ve been able to install neovim and emacs with nix-env -i but I can’t do the same with RStudio. I’d also appreciate help in understanding how I may/should install RStudio and other similar packages. Thanks.

nix-env command:

nix-env -iA nixpkgs.rstudioWrapper

there is also an rstudio package, but it lacks the qt plugin wrapping so you get:

$ ./result/bin/rstudio
qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Side note: nix-env is there to simulate a similar install process to other package managers. But it loses out on a lot of the potential gains you get from nixpkgs (E.g. declarative properties, reproducibility). I would look into GitHub - nix-community/home-manager: Manage a user environment using Nix [maintainer=@rycee] for creating an actual “profile” that leverages the power of nix.

Thanks for the suggestion. When I execute the above in Mac OS, I get the following error:

installing ‘RStudio-1.2.1335-wrapper’
error: Package ‘RStudio-1.2.1335’ in /nix/store/25q78bckai9szsc5wv5ndr10c4b1wghv-nixpkgs-20.03pre207249.7e8454fb856/nixpkgs/pkgs/applications/editors/rstudio/default.nix:128 is not supported on ‘x86_64-darwin’, refusing to evaluate.

a) For nixos-rebuild you can set
{ nixpkgs.config.allowUnsupportedSystem = true; }
in configuration.nix to override this.

b) For nix-env, nix-build, nix-shell or any other Nix command you can add
{ allowUnsupportedSystem = true; }
to ~/.config/nixpkgs/config.nix.

Any ideas on how I could/should resolve this with respect to Mac OS? Thanks.

I don’t see anything linux specific in the expression. Someone with access to darwin hardware would have alter the expression to support darwin use case.