cachix / devenv

Fast, Declarative, Reproducible, and Composable Developer Environments
https://devenv.sh
Apache License 2.0
4.46k stars 335 forks source link

Can't follow nixpkgs version provided by custom flake #1049

Closed imincik closed 5 months ago

imincik commented 7 months ago

Describe the bug Devenv is crashing when I try to follow nixpkgs version provided by custom flake.

To reproduce I want to use nixpkgs in the version as my geospatial-nix flake is using:

✖ Command produced the following output:

✔ Building shell in 0.2s. Error: × Command /nix/store/16z8qb8j04nzahvxgms9wn9qba1fjh4z-nix-devenv-2.21.0pre20240315_c5bbf14/bin/nix --show-trace --extra-experimental-features nix-command --extra-experimental-features flakes --option warn-dirty false --option eval- │ cache false --keep-going --max-jobs 8 print-dev-env --profile /home/imincik/tmp/devenv-1-follow/.devenv/gc/shell failed with with exit code 1

**Version**

Paste the output of `$ devenv version` here.

devenv 1.0.1 (x86_64-linux)

imincik commented 7 months ago

.devenv/devenv.json file is created correctly

{
  "inputs": {
    "nixpkgs": {
      "follows": "geonix/nixpkgs"
    },
    "geonix": {
      "url": "github:imincik/geospatial-nix"
    }
  }
}

but .devenv/flake.json is not (it is missing follows and contains not existing url)

{
  "nixpkgs": {
    "url": null,
    "inputs": {},
    "flake": true
  },
  "geonix": {
    "url": "github:imincik/geospatial-nix",
    "inputs": {},
    "flake": true
  }
}
imincik commented 7 months ago

Looks like we could just add follows to FlakeInput https://github.com/cachix/devenv/blob/ad5a82f493f016bf4e82fae481b374d943be9560/devenv/src/config.rs#L38 .

Something like this:

diff --git a/devenv/src/config.rs b/devenv/src/config.rs
index 61383b8..45883ab 100644
--- a/devenv/src/config.rs
+++ b/devenv/src/config.rs
@@ -37,6 +37,7 @@ impl Input {
 #[derive(Serialize, Deserialize, Debug)]
 pub struct FlakeInput {
     pub url: Option<String>,
+    pub follows: Option<String>,
     pub inputs: HashMap<String, Input>,
     pub flake: bool,
 }
@@ -45,6 +46,7 @@ impl From<&Input> for FlakeInput {
     fn from(input: &Input) -> Self {
         FlakeInput {
             url: input.url.clone(),
+            follows: input.follows.clone(),
             inputs: input.inputs.clone(),
             flake: input.flake,

but with make sure that only one of url or follows can exist. I remember I did the same patch for Python CLI. Doing it in Rust is currently too much for me.