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

rstudio-server: Initial commit for rstudio-server and associated wrapper #95831

Merged
merged 4 commits into from Jan 17, 2022

Conversation

cfhammill
Copy link
Contributor

Motivation for this change

Documented in more detail at https://discourse.nixos.org/t/adding-rstudio-server-r/8644/4, but in short, I wanted to be able to run rstudio-server inside a nix-shell so that I could get plots faster than using X-forwarding.

Things done

Modified the rstudio build code to build the server version, with some more tweaks.

Coarse diff between rstudio and rstudio-server:

  1. Nix file is under the same directory as rstudio. Called server.nix
  2. Added to top-level as rstudio-server
  3. Calls wrap program on each binary
  4. Adds readline6 and pam dependencies for building
  5. Removes reference to icons (build failed if left in)

Coarse diff between rstudioWrapper and rstudioServerWrapper

  1. Uses the same libPath wrapping on the rsession binary
  2. Also adds a fontconfig dependency and wrapping to fix the plot fonts issue noted here
  3. Wraps rserver to point to the wrapped rsession

Potential To-Do's

  • I think the rstudio-server build could be refactored into the same nix file as the rstudio build, adding an argument to toggle between the two.
  • I think this could be converted into a NixOS module and made to work with pam. For now it's simple enough to write a a small script to simple authentication (this can be passed to rserver as the --auth-pam-helper argument if memory serves.)
  • I think that rstudioWrapper and rWrapper should be given the same fontconfig fix as rstudioServerWrapper but perhaps that's best for another PR.

CC @ehmry @changlinli @ciil

  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • [ x ] other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • [ x ] Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • [ x ] Fits CONTRIBUTING.md.

@cfhammill cfhammill requested a review from peti as a code owner August 20, 2020 03:25
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/adding-rstudio-server-r/8644/6

@alexvorobiev
Copy link
Contributor

Thank you for adding the server! Are you planning to add a corresponding NixOS module for the service?

@cfhammill
Copy link
Contributor Author

Hi @alexvorobiev, I've actually never used NixOS so I wouldn't know where to start with adding a module. My colleague @bcdarwin has offered to help creating a module if this PR goes through.

@nviets
Copy link
Contributor

nviets commented Sep 28, 2020

Any update on this PR?

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/adding-rstudio-server-r/8644/7

pkgs/development/r-modules/wrapper-rstudio-server.nix Outdated Show resolved Hide resolved
pkgs/development/r-modules/wrapper-rstudio-server.nix Outdated Show resolved Hide resolved
pkgs/applications/editors/rstudio/server.nix Outdated Show resolved Hide resolved
pkgs/applications/editors/rstudio/server.nix Outdated Show resolved Hide resolved
pkgs/applications/editors/rstudio/server.nix Outdated Show resolved Hide resolved
pkgs/applications/editors/rstudio/server.nix Outdated Show resolved Hide resolved
pkgs/applications/editors/rstudio/server.nix Outdated Show resolved Hide resolved
pkgs/applications/editors/rstudio/server.nix Outdated Show resolved Hide resolved
pkgs/development/r-modules/wrapper-rstudio-server.nix Outdated Show resolved Hide resolved
pkgs/top-level/all-packages.nix Outdated Show resolved Hide resolved
@jonringer
Copy link
Contributor

* I think the `rstudio-server` build could be refactored into the same nix file as the `rstudio` build, adding an argument to toggle between the two.

If rstudio-server used mkDerivation, I would say use passthru.unwrapped to allow a reference to the underlying package, but I'm not sure if runCommand filters those attrs

Copy link
Member

@SuperSandro2000 SuperSandro2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please format your code with nixpkgs-fmt

pkgs/applications/editors/rstudio/server.nix Outdated Show resolved Hide resolved
pkgs/applications/editors/rstudio/server.nix Outdated Show resolved Hide resolved
pkgs/applications/editors/rstudio/server.nix Outdated Show resolved Hide resolved
pkgs/applications/editors/rstudio/server.nix Outdated Show resolved Hide resolved
pkgs/applications/editors/rstudio/server.nix Outdated Show resolved Hide resolved
@stale
Copy link

stale bot commented Sep 19, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Sep 19, 2021
@alexvorobiev
Copy link
Contributor

This is still important

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Sep 22, 2021
@nviets
Copy link
Contributor

nviets commented Sep 22, 2021

What is pending for this update to be released?

pkgs/applications/editors/rstudio/server.nix Outdated Show resolved Hide resolved
pkgs/applications/editors/rstudio/server.nix Outdated Show resolved Hide resolved
pkgs/applications/editors/rstudio/server.nix Outdated Show resolved Hide resolved
pkgs/applications/editors/rstudio/server.nix Outdated Show resolved Hide resolved
pkgs/development/r-modules/wrapper-rstudio-server.nix Outdated Show resolved Hide resolved
pkgs/development/r-modules/wrapper-rstudio-server.nix Outdated Show resolved Hide resolved
@billksun
Copy link
Contributor

@cfhammill, are you available to make the review edits? I am in need of this as well.

@cfhammill
Copy link
Contributor Author

sorry for the delay, I'm back looking at this now and will hopefully have a chance to make the requested revisions soon

@jbedo
Copy link
Contributor

jbedo commented Dec 6, 2021 via email

@cfhammill
Copy link
Contributor Author

thanks @jbedo I was wondering if redoing this PR off the updated rstudio/default.nix, this was the push I needed.

@cfhammill
Copy link
Contributor Author

cfhammill commented Dec 8, 2021

I have the new version of rstudio-server building based on the updated rstudio derivation. A couple of pain points

The rstudio-server service doesn't work, you have to use the rserver binary directly. This is probably the best we can do for non-nixOS systems.

rserver as far as I can tell requires a few system directories that need to be writeable. I never noticed this before because my systems had those directories around from non-nix installs of rstudio server. the directories in question are

  • /var/run/rstudio-server (this needs to have global write with the sticky bit set according to rserver, but ostensibly this location can be changed with the --server-data-dir flag)
  • /var/lib/rstudio-server (needs some write permissions, not sure if it needs to be global, but as far as I can tell this cannot be moved to another directory)

so a user wanting to run rstudio-server would run
sudo mkdir /var/run/rstudio-server && sudo chmod a+wt /var/run/rstudio-server
sudo mkdir /var/lib/rstudio-server && sudo chmod a+wt /var/lib/rstudio-server

once, and then to launch the server the user would run

rserver --auth-none 1

possibly in the background.

If anyone has any clever ideas to avoid the global directories I'd welcome a contribution. We could probably patch the CMake files or the c++ source code to override these default locations and point them elsewhere, not sure where, I think write perms within the nix store is a no-go, if we can't think of a sensible default, an upstream PR to add an argument to move the /var/lib/rstudio-server location might be possible.

@jbedo
Copy link
Contributor

jbedo commented Dec 8, 2021 via email

@cfhammill
Copy link
Contributor Author

@bcdarwin has offered to help turn this into a module, do you mean this would work for a non-nixOS system? If so can you give me more detail on what to do?

@cfhammill cfhammill requested a review from jbedo as a code owner December 8, 2021 06:02
@cfhammill
Copy link
Contributor Author

All sounds good to me, I didn't test myself, booted in to a nixos vm, tried a few things couldn't get basic stuff going and gave up, but if you both are giving thumbs up I'm sure it's fine.

Shall I squash in prep for merge or @jbedo will you squash merge?

@jbedo
Copy link
Contributor

jbedo commented Jan 6, 2022

It would be better if you could squash this down to a couple of commits, one adding the rstudio-server expression and another adding the module + tests. There's now a conflict with the ids to resolve, just needs to be bumped.

@bcdarwin
Copy link
Member

bcdarwin commented Jan 10, 2022

Squashed, uid/gid updated, and rebased onto master.

@bcdarwin
Copy link
Member

Added the new module to the release notes as per updated contributing guidelines.

@jbedo should be ready to merge.

Copy link
Contributor

@jonringer jonringer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise diff LGTM at a glance.

Would like for a rstudio user to verify


desktopItems = [
(makeDesktopItem {
name = "${pname}";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name = "${pname}";
name = pname;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@jbedo
Copy link
Contributor

jbedo commented Jan 11, 2022

LGTM too, I'll see if I can find an rstudio-server user to test this more but pretty confident in the basic functionality as @bcdarwin has also verified it.

@bcdarwin
Copy link
Member

bcdarwin commented Jan 12, 2022

The example value for services.rstudio-server.package (currently pkgs.rstudioServerWrapper.override { packages = [ pkgs.rPackages.ggplot2 ]; }) does not build due to a dangling symlink issue with the wrapper:

error: not a directory: `/nix/store/svhiws2l6jn7ygl4zx0yjg10i7i9yr43-RStudio-1.4.1717-wrapper/share'

However, I don't have time to look into it this week.

@jbedo
Copy link
Contributor

jbedo commented Jan 12, 2022 via email

@bcdarwin
Copy link
Member

Resolved. Added a crappy test for it too.

Works now, thanks.

@bcdarwin
Copy link
Member

Rebased and resolved merge conflicts again.

CHRIS hammill and others added 4 commits January 17, 2022 10:24
Co-authored-by: Justin Bedo <cu@cua0.org>
Co-authored-by: Jonathan Ringer <jonringer@users.noreply.github.com>
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
Co-authored-by: Benjamin Darwin <bcdarwin@gmail.com>
@jbedo
Copy link
Contributor

jbedo commented Jan 16, 2022

We can merge this once the checks have passed, hopefully before we have to deal with further conflicts. @jonringer I think further issues are likely to be more fundamental problems with the underlying R/RStudio expressions rather than the rstudio-server module, which we can deal with separately.

@jbedo jbedo merged commit dfa93a4 into NixOS:master Jan 17, 2022
@jonringer
Copy link
Contributor

I'm fine with incremental improvement. And I'm not familiar with r to really guide to the desired end state.

Thanks for reviewing it

@bcdarwin bcdarwin deleted the cfh/add-rstudio-server branch January 17, 2022 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants