-
Notifications
You must be signed in to change notification settings - Fork 16
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
Support [experimental] flakes #53
Comments
@b-rodrigues I am currently exploring devbox get some more recent nix package versions for specific software (e.g. need to have up to date quarto for certain extensions, which really quick to get via this approach. I really like this in combination with nixhub.io |
There's also this: https://devenv.sh/ several things that we could explore! |
When I started my Nix journey, I decided to follow the flake path from the beginning. So naturally, when I found out about rix, I immediately started thinking how to have a flake-enabled version of it. It could be an option with I can see two ways to make this happen.
Which way would you prefer? |
The thing I'm still wondering is what use case flakes solve/make easier than the current setup? I'm not necessarily against support flakes per se, but I'd like to know what I'm missing. I'm not necessarily convinced that flakes are a useful abstraction for development envs. What am I missing? |
Here's a summary in case you haven't read it: https://www.tweag.io/blog/2020-05-25-flakes/#what-problems-do-flakes-solve For example, we could define an environment with whatever packages, and ship all the IDEs in a single flake. You could choose which one is the default. We could also ship docker container artifacts, which one could build in case you want to share your env with non nix users. There are many possibilities |
I started a nix project like that, but rix is a better approach for R users, who don't know nix yet. |
What do you think would be the impact on the current codebase of supporting flakes? Seems like option 2 would be the best, and also still have minimal impact? |
I'm not familiar enough with the code base to be able to fully grasp the impact. But I think we can work with the current functions, and perhaps write a few more. Probably we'll need a dependency on gitr, because flakes only see files that are tracked by git. I also wonder whether it would make sense to wrap some of the functionality of nix into R functions. I'm thinking I think of creating a flake template somewhere in |
Composing environments does sound appealing , especially having one for packages and another for IDEs 🤔 Feel free to hack it together 😁 |
I am in favor of option 2 of implementing it. We can get both, separation of concerns but also reuse the existing function stack for boilerplating. @Kupac I'm sure there is still parts in the traditional way that we can function up more efficiently for both default channels and flake ways. We can follow the approach we used for We should definitively default for channels, but why not add flakes for those who want/need them. Regarding the need of gitr: does look quite nice, but I'd be hesistant adding another strict dependency to the list because it is a reproducibility package. We could also use |
FYI, I started to read the code base, and think about how to actually do this flake thing. Thanks for the pointers above, I agree 100%, and there are some good ideas in there. |
I played around with flakes a bit and created a repo that automatically generates flake templates based on the available dates and versions: https://github.com/dwinkler1/rix-flakes For now the flakes are all based off of my own preference shown here with just the R version changed: https://github.com/dwinkler1/rix-flakes/tree/main/templates/radian_vscode It should be possible to use similar templates and instead of declaring the R packages in the templates like here: rix could just generate the package list and paste that into a rpackages.nix file that is imported. This what I do in my home config:
Where r-packages.nix is:
|
Nice work! I like the idea of simply listing packages and providing those to various envs: radian/rstudio, etc. Before doing that, we also need to override the R package tree (
And import the package list afterwards. I think the rix code has most of this functionality in place. You think we could easily merge your templates in there? BTW, I have a similar (but less mature) effort at: https://codeberg.org/kupac/reproducibR We could work together to add flake support to rix. |
Sounds good! Looking at https://docs.ropensci.org/rix/articles/d1-installing-r-packages-in-a-nix-environment.html#installing-old-packages-archived-on-cran and https://docs.ropensci.org/rix/articles/z-advanced-topic-handling-packages-with-remote-dependencies.html it seems like we can just use whatever rix is already generating. I have this pretty much (except for the specific package versions) set up manually in my home config:
We just need to figure out where to hook into rix to generate the statements and dump them into a package file. I'd say it's probably nicer to combine
We can either merge the flakes here or fork a separate repo under |
I haven't looked into flakes yet (I've been using Nix for two years now, shame on me lmao) but I am not against adding support for flakes in rix. But I would need commitment from the both of you to maintain this as I wouldn't be able to. |
I updated the generated flakes so that we can use the existing #! /bin/sh
sed -i '1s/^/pkgs:\n/;/^\s*pkgs = import (fetchTarball/d;s/^\s*pkgs.mkShell//' default.nix This generates a function of See new default: https://github.com/dwinkler1/rix-flakes/blob/14c771359fe4ca697fa0c22147ae5127e6ca4afe/templates/default/flake.nix |
I believe that if we implement it correctly, and not mess it up too much, then it should be minimal maintenance. Let's create a branch or a few branches first, and we can agree on the responsibilities before merging. Or wait! We can also just call it "experimental" ... I saw that somewhere... |
I'm not sure if this will create headaches for users but flakes also allow extra-substituters to be specified:
Works fine for me but I think we should test this on a new setup first. |
Just to be clear: we're aiming for R code within rix that generates a valid flake, right? Or are you thinking to call out to your rix-flake from rix to get the template? |
BTW, here's some changes I started to make a few months ago. Quite far from where I'd like it to be. |
I think that's just an implementation detail at the end. I have a slight preference for having the basic flakes generated already because this would be useful separately for nix users. But I can also run that entirely separately from rix in the flakes repo. What I very strongly prefer is that we use as much of the existing rix code as possible by generating a file that is imported into the flake. As far as I can see that would require only two functions to change ie take a flakes flag: the one generating the header and the one generating the shell. The changes are trivial and we would get a valid nix file. We could then have the flake template as part of rix and add only the appropriate url for the repo or call nix flake init to a separate repo with the appropriate flake there. Generating the flakes is done via GitHub actions and is relatively fast (~30 sec) so I could schedule it to update twice a day. |
I would be very much in favour of merging such a PR! Would there be the need to add a further function in rix to add the appropriate url or call nix flake init in a separate folder? Anything else that rix could offer to the user to make it even easier? |
I still need to figure out the url. Flakes work a bit differently since they have their own lock file so I think the distinction of Other than that a flakes deployment would generate a file similar to the current
We could build a wrapper around |
Just to make sure:
Just FYI this is what the
|
yep, that’s right there’s also dated branches, as you know |
Awesome. We can already handle the date branches and r versions automatically. I was worried about generating the FYI the flakes handle missing files gracefully but are just useless :) |
that sounds like a reasonable default. Also, could I be greedy and ask if you open a PR, that you also add some pointers for a vignette, something like "Why use flakes" something to that effect? To make them easier to introduce to beginners (let me be clear, that’s not like it would be a blocker for merging, but it would help me draft something). |
Sure, give me a few weeks; I need to finish my thesis first. :) I expected this addition to be much more complicated and take more discussion. If anyone wants to test in the meantime I have the templates at: https://github.com/dwinkler1/rix-flakes/blob/main/templates.nix The script to patch the current In addition to
Running from |
sure, good luck 😄 |
just to list; somewhen in future when we are bored and done with backbone of {rix}
The text was updated successfully, but these errors were encountered: