cachix / devenv

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

Feature request: flag to not initiate a download #684

Open stuzenz opened 10 months ago

stuzenz commented 10 months ago

One thing I noticed with devenv shell vs nix shell or nix develop is that quite often the devenv shell command will execute a download.

For the below relatively simple environment there is about 60MB downloaded. I do enough coding while on trains etc. whilst tethered on my phone that the forced download is a bit of a problem - both due to the data use and also because of the network.

It would be great if a flag was available to tell devenv to build the environment without doing a download.

From a usability perspective, I am not even sure if the flag should be the option or the default. If by habit we don't use the flag, I am wondering about the following scenario. A user runs the default nix develop command and then ctrl-c out of it due to a preference not to kick off an attempt at a download. I guess as long as the old cached paths are still valid (which I guess they will be as nothing would commit to new store/cache linked paths yet) and the command again with the flag should work fine.

One thing I am curious about, what are the conditions that determine whether devenv will or will not do a download?

{ pkgs, ... }:

{
  name = "azure-devops-python311";
  packages = [  pkgs.python311Packages.jupyterlab pkgs.python311Full pkgs.gcc.cc.lib]; # pkgs.gcc.cc.lib
  languages.python = {
    enable = true;
    poetry.enable = true;
  };
}
thenonameguy commented 10 months ago

Devenv itself does not do downloads, the underlying Nix evaluation does. It reaches out to substitutes (or sources) when it has missing packages (derivations) that are needed to realize whatever it is evaluating. Here is a handy blog post that describes the process, plus some unrelated pitfalls.

This means once your example devenv.nix environment was once successfully initialized, all the necessary things should be on your machines' Nix store.

Can you please try turning off internet connectivity and running devenv shell and posting the output? If your hypothesis is true, it should fail, since you need to download the mentioned packages.

domenkozar commented 1 month ago

I think that's being discussed here is refetching of nixpkgs, I want to look into how we can more aggressively cache that.

domenkozar commented 3 weeks ago

We do support --offline now, but that doesn't cover the tarballs.