Mehrad,
@Mehrad@fosstodon.org avatar

A question for and folks:

I want to start a R project and I want to keep everything about this project static and frozen in time. I know nix-shell is a thing, but:

  1. is there a better/smoother approach?

  2. is it possible to also have a service/daemon running in that nix-shell ? The editor I use (Rstudio) has desktop and server versions, and I would rather have the server version running on a beefy remote machine and I ssh into it.

Boosting is highly appreciated :)

kupac,
@kupac@functional.cafe avatar

@Mehrad
You can generate a systemd service in nix, but I never tried it myself (only on NIxOS).

I do run nix-defined rstudio server routinely by hand and connect to it remotely. So it is possible, but never documented it :) anyone else?

Mehrad,
@Mehrad@fosstodon.org avatar

@kupac
Good to know that I'm not alone in this🤓. Can you share the experience and possibly some code snippets?

wamserma,
Mehrad,
@Mehrad@fosstodon.org avatar

@wamserma
Thanks for the suggestion. The more I look into this, the more I feel like it is adding an extra layer of yaml abstraction on top of flakes.

They also "support" R language but based on my limited understanding of nix syntax, they have only put R binary there without pinning the versions:

https://github.com/cachix/devenv/blob/main/src%2Fmodules%2Flanguages%2Fr.nix

So I'm not sure how useful and deterministic it is. Have you used it? Does it provide things that flakes can't?

RossGayler,
@RossGayler@aus.social avatar

@Mehrad

@brodriguesco is this a use case for {rix}?

Mehrad,
@Mehrad@fosstodon.org avatar

@RossGayler
based on what I understand from {rix} documentation, I'd argue "no" because {rix} is an R package itself. I want to put R, R packages, and Rstudio all in a reproducible frozen state. basically one project, one dedicated environment.

Do you think this can be done by {rix}? If so, would you please point me to the correct direction.
@brodriguesco

kupac,
@kupac@functional.cafe avatar

@Mehrad
{rix} will just help you generate the Nix expression you need for that fully reproducible environment. It will not be needed later and won't be included in the environment unless you declare it. You can give it a try, what can you lose?
@RossGayler @brodriguesco

brodriguesco, (edited )
@brodriguesco@fosstodon.org avatar

yep, that's exactly as @kupac explains! rix just helps you generate the expression. you don't need to have it in the environment and don't need even need Nix installed to generate the expression. I've rewritten the vignettes this week would be amazing to have your opinion on it!

https://b-rodrigues.github.io/rix/articles/a-getting-started.html

@Mehrad @RossGayler

bioinformatician_next_door,
@bioinformatician_next_door@kafeneio.social avatar

@Mehrad @RossGayler @brodriguesco
Isn't it easier to just make a docker container that includes the Rstudio server, R, R packages etc?
have a look at this:
https://github.com/ConYel/dashboard_survey/blob/main/dashboard_container/Dockerfile

brodriguesco,
@brodriguesco@fosstodon.org avatar

@bioinformatician_next_door @Mehrad @RossGayler Depends what you want to achieve. Docker is nice once the project is done and want to deploy/rebuild, but not so nice to work interactively, for example. And strictly speaking, docker images are not entirely reproducible (unless you go through a lot of pains to make them, like using digests for example)

Mehrad,
@Mehrad@fosstodon.org avatar

@bioinformatician_next_door

I second this. Docker is a pain to work with in an on-going project. Also it consumes a lot of disk space because of all those images it builds during an ongoing project. Generally renv works better with much less overhead, unless you be very careful in defining version of everything (including OS, binaries, etc.) in your docker. For me it was such a pain that I stopped using it entirely.

@brodriguesco @RossGayler

🧵👇

Mehrad,
@Mehrad@fosstodon.org avatar

🧵👆

@bioinformatician_next_door

Of course, if you have a working example, I'm very very interested to read the docker file and learn more 🤓 I'm not a docker expert by any stretch, which means there are a ton of things that I can learn.

@brodriguesco @RossGayler

brodriguesco,
@brodriguesco@fosstodon.org avatar

@Mehrad tbf, Nix also takes up quite a lot of space

bioinformatician_next_door,
@bioinformatician_next_door@kafeneio.social avatar

@brodriguesco @Mehrad @RossGayler
Well I have worked with R studio server on Docker during my PhD and I can say for 2 years I didn't have any issues on reproducibility once I learnt how to use it and bind correctly my datasets folders.
And depends on the images that you use.
I know for sure that can be quite reproducible to the bit.

brodriguesco,
@brodriguesco@fosstodon.org avatar

@bioinformatician_next_door @Mehrad @RossGayler yes, in practice it’s rarely an issue, I’ve used Docker quite a lot and still do, I mainly use the Rocker images + renv for reproducibility. I think that Nix offers a simpler solution though.

bioinformatician_next_door,
@bioinformatician_next_door@kafeneio.social avatar

@brodriguesco @Mehrad @RossGayler
Regarding Rocker images, at first I was using them too but were/are quite heavy so I started using the one with base alpine from https://r-hub.github.io/rhub/
I haven't worked with Nix but I would be happy to test it if there is something streamlined already.

brodriguesco,
@brodriguesco@fosstodon.org avatar

@bioinformatician_next_door take a look at our package, rix, which makes using Nix for R users much easier: https://b-rodrigues.github.io/rix/

still in development, but a cran release will happen soon we hope! @specphil

specphil,
@specphil@fosstodon.org avatar

@brodriguesco @bioinformatician_next_door with_nix() is a relatively new feature. I https://b-rodrigues.github.io/rix/articles/z-advanced-topic-running-r-or-shell-code-in-nix-from-r.html It enables the comparison of outputs from production code across different R environments in a straightforward, declarative, and interactive manner, leveraging the power of along with the capabilities of {codetools} and {sys}. We would greatly appreciate proactive feedback on this functionality, just as we value input on other use cases.

AngryAnt,
@AngryAnt@mastodon.gamedev.place avatar

@Mehrad You can certainly tie shells and services and scripts together.

In many ways. A lot more context is needed to figure out which ways work beat for your case :)

"Better/smoother" also needs some context/direction :)

Mehrad,
@Mehrad@fosstodon.org avatar

@AngryAnt
I was just typing it 😅 so I cut-paste them here:

Just to add a little bit of context, yes, I want to have R language, all used libraries and their dependencies (fortran, gcc), and even the IDE all enclosed for this project for the sake of reproducibility.

Let me know what else you would want to know 🤓

ahoneybun,
@ahoneybun@hachyderm.io avatar

@Mehrad @AngryAnt if you need to lock it to a certain version I feel like flakes would be the go to? It has a .lock file just like Rust does with it's Cargo.lock file.

Mehrad,
@Mehrad@fosstodon.org avatar

@ahoneybun
Thanks, I'm a bit hazy about the whole Flakes concept. I've spent hours watching videos, reading blog posts, going through the the manual. It seems those who know what flakes are don't put it in simple terms for us n00bs. 😅

Here is an example:

https://nixos.org/manual/nix/stable/contributing/experimental-features.html?highlight=flakes#flakes

Can you point me to the correct direction of what Flakes are and how they are useful in my case compared to nix-shell default.nix

@AngryAnt

AngryAnt,
@AngryAnt@mastodon.gamedev.place avatar

@Mehrad Sure, that's all possible. I'd assume you already know how to add all those.

But I'm not sure how that describes the service interaction you're interested in or the "better/smoother" you're after :)

Mehrad,
@Mehrad@fosstodon.org avatar

@AngryAnt
>> I'd assume you already know how to add all those.

Not really, but I can probably monkey my way into making a default.nix that works (my previous experience is with Guix, so I understand the concept in some level). But if you have any blog post, help page or git repo that can reduce my trial-and-error, that would be superb 😬

As for the service, my idea was to start a nix-shell and it starts the service/daemon. This way I can work on that project and then just close that shell.

AngryAnt,
@AngryAnt@mastodon.gamedev.place avatar

@Mehrad Ah. In that case I would probably approach it as a shell script which runs those two - the service and the shell - one after another, referencing the same shell nix file.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • NixOS
  • GTA5RPClips
  • DreamBathrooms
  • InstantRegret
  • ethstaker
  • magazineikmin
  • Youngstown
  • thenastyranch
  • mdbf
  • slotface
  • rosin
  • modclub
  • kavyap
  • cisconetworking
  • osvaldo12
  • JUstTest
  • khanakhh
  • cubers
  • Durango
  • everett
  • ngwrru68w68
  • tester
  • normalnudes
  • tacticalgear
  • anitta
  • megavids
  • Leos
  • provamag3
  • lostlight
  • All magazines