Skip to content

Commit

Permalink
r_ecosystem_track integrated
Browse files Browse the repository at this point in the history
  • Loading branch information
TyberiusPrime committed Nov 24, 2021
1 parent 61bdde4 commit 2ae99d6
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "anysnake2"
version = "0.8.3"
version = "0.9.0"
authors = ["Florian Finkernagel <[email protected]>"]
edition = "2018"

Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,13 @@ Just include this:
```toml
[R]
# you get whatever packages were current that day.
r_ecosystem_track_rev="2021-10-11_v1" # a tag or revision from the r_ecosystem_track repo
ecosystem_tag="2021-10-28_v1" # a tag or revision from the r_ecosystem_track repo
packages = [
"ggplot2",
]
```

(Note: r_ecosystem_track is not ready yet, and not integrated into anysnake2 as of 2021-19-10,
but this is how it's going to work. For now ,the r packages come from nixpkgs).

(Visit r_ecosystem_track and look at it's tags for available versions)


# Using rust
Expand Down
7 changes: 3 additions & 4 deletions examples/dev/anysnake2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ packages = [ # use https://search.nixos.org/packages to search
"which",
"mercurial", # good test case for breaking site-packages
"evcxr",
"rWrapper.override{ packages = with rPackages; [ ggplot2 dplyr xts ]; }",
] # optional

[outside_nixpkgs]
Expand Down Expand Up @@ -72,11 +71,11 @@ mbf_r="@mbf"
mbf_sampledata="@mbf/mbf_sampledata"

[R]
ecosystem_date="2021-10-11" # you get whatever packages were current that day.
ecosystem_tag="2021-05-20_1" # you get whatever packages were current that day.
packages = [
"ggplot2",
"affy",
"IRkernel",
"dplyr",
"xts",
]

[flakes.hello]
Expand Down
4 changes: 2 additions & 2 deletions examples/full/anysnake2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ mbf_sampledata="@mbf/mbf_sampledata"


[R] # R section is optional
r_ecosystem_track_rev="2021-10-11_v1" # you get whatever packages were current that day.
# r_ecosystem_track_rev= "github:TyberiusPrime/r_ecosystem_track" # optional
r_ecosystem_tag="2021-10-28_1" # you get whatever packages were current that day.
# r_ecosystem_track_url= "github:TyberiusPrime/r_ecosystem_track" # optional
packages = [
"ggplot2",
"affy",
Expand Down
25 changes: 14 additions & 11 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,19 @@ pub struct ConfigToml {
pub flakes: Option<HashMap<String, Flake>>,
#[serde(default)]
pub dev_shell: DevShell,
#[serde(rename="R")]
#[serde(rename = "R")]
pub r: Option<R>,

}

impl ConfigToml {

pub fn from_str(raw_config: &str) -> Result<ConfigToml> {
let mut res: ConfigToml = toml::from_str(&raw_config)?;
res.anysnake2.url = match res.anysnake2.url {
Some(url) => Some(url),
None => {
match res.anysnake2.use_binary {
true => Some("github:TyberiusPrime/anysnake2_release_flakes".to_string()),
false => Some("github:TyberiusPrime/anysnake2".to_string()),
}
}
None => match res.anysnake2.use_binary {
true => Some("github:TyberiusPrime/anysnake2_release_flakes".to_string()),
false => Some("github:TyberiusPrime/anysnake2".to_string()),
},
};
Ok(res)
}
Expand All @@ -65,7 +61,6 @@ pub struct Anysnake2 {
}

impl Anysnake2 {

fn default_use_binary() -> bool {
true
}
Expand Down Expand Up @@ -239,8 +234,16 @@ impl Default for Container {

#[derive(Deserialize, Debug)]
pub struct R {
pub ecosystem_date: String,
pub ecosystem_tag: String,
pub packages: Vec<String>,
#[serde(default = "R::default_url")]
pub r_ecosystem_track_url: String,
}

impl R {
fn default_url() -> String{
"github:TyberiusPrime/r_ecosystem_track".to_string()
}
}

fn parse_my_date(s: &str) -> Result<chrono::NaiveDate> {
Expand Down
12 changes: 10 additions & 2 deletions src/flake_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,18 @@ pub fn write_flake(

flake_contents = match &parsed_config.r {
Some(r_config) => {
inputs.push(InputFlake::new(
"r_ecosystem_track",
&r_config.r_ecosystem_track_url,
&r_config.ecosystem_tag,
&["flake-utils"],
&flake_dir
)?);

let r_packages = format!(
"
r_packages = with pkgs.rPackages; [ {} ];
rWrapper = pkgs.rWrapper.override{{ packages = r_packages; }};
r_packages = with r_ecosystem_track.rPackages.${{system}}; [ {} ];
rWrapper = r_ecosystem_track.rWrapper.${{system}}.override{{ packages = r_packages; }};
",
r_config.packages.join(" ")
);
Expand Down

0 comments on commit 2ae99d6

Please sign in to comment.