devenv: Encountered "Failed to get cachix caches due to evaluation error" when running `devenv shell` command

Describe the bug

I follow the getting started guide and try to run a minimal devenv sample file like this

{ pkgs, ... }: {
  env.GREET = "determinism";

  packages = [ pkgs.git ];

  enterShell = "echo hello $GREET";
}

But I saw output like this

• Building shell ...
• Failed to get cachix caches due to evaluation error

While the devenv shell eventually built all the dependencies and enter the shell successfully, but it seems like the command is not using the cache as it supposes to be. I dug a bit deeper, and I realized that’s caused by let ... in syntax used in the generated flake file by these lines:

https://github.com/cachix/devenv/blob/63c7109f20b5ded0bc07f95ece9518bbb7fdea5b/devenv/src/flake.tmpl.nix#L3-L5

And if you looked at the generated flake file .devenv.flake.nix, it’s like this

{
  inputs =
    let
      version = "1.0.1";
system = "x86_64-linux";
devenv_root = "/home/fangpen/workspace/playground/try-out-devenv2";
devenv_dotfile = ./.devenv;
devenv_dotfile_string = ".devenv";
container_name = null;
tmpdir = "/run/user/1000/";

        in {
...

Unfortunately, it appears that flake.nix is not using real nix language:

https://github.com/NixOS/nix/issues/4945

As a result, if you take out the generated flake file at .devenv.flake.nix, renamed it as flake.nix and run the same command as in the code.

nix eval  .#devenv.cachix --json
error: expected a set but got a thunk at /nix/store/qny7kiz6ns713q8w2lgmjyrms3hg0jds-source/flake.nix:2:

It will show an error like that. It’s the root cause of error message like Failed to get cachix caches due to evaluation error.

To reproduce

To reproduce, simply install devenv 1.0.1, then run devenv shell with sample file such as

{ pkgs, ... }: {
  env.GREET = "determinism";

  packages = [ pkgs.git ];

  enterShell = "echo hello $GREET";
}

Version

devenv 1.0.1 (x86_64-linux)

and the nix version is

nix (Nix) 2.18.1

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 4
  • Comments: 25 (12 by maintainers)

Commits related to this issue

Most upvoted comments

@tomtaylor I found a way to reproduce it myself, fix incoming.

Alright, let me know, I’d like to fix this and then we can release 1.0.2

Yeah, you’ll have to suffer through that until we fix this issue.

OK, I’ll come back to you once 782 packages have built! 😃

I’ll look into this first thing in the morning tomorrow.