Skip to content

How to use devenv up in pure eval mode? #1765

@gabyx

Description

@gabyx

Currently I use a custom flake input "variable" devenv-root to not need --no-pure-eval (hack/workaround)

 nix develop --accept-flake-config --override-input devenv-root "path:.devenv/state/pwd" "./tools/nix#default"

Where in my flake I have defined these inputs

    # The devenv module to create good development shells.
    devenv = {
      url = "github:cachix/devenv";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    devenv-root = {
      url = "file+file:///dev/null";
      flake = false;
    };

and makeShell to do this

    inputs.devenv.lib.mkShell {
      modules = [
        (
          { ... }:
          {
            devenv.flakesIntegration = true;
            # This is currently needed for devenv to properly run in pure hermetic
            # mode while still being able to run processes & services and modify
            # (some parts) of the active shell.
            devenv.root = builtins.readFile inputs.devenv-root.outPath;
          }
        )
        ({ ... }: /* other stuff */)
      ];
    };

In .envrc I do this to write the .devenv/state/pwd file

# This is currently needed for devenv to properly run in pure hermetic
# mode while still being able to run processes & services and modify
# (some parts) of the active shell.mkdir -p .devenv/state
# See: https://github.com/cachix/devenv/issues/1461
if [ ! -f .devenv/state/pwd ] ||
    [ "$(pwd)" != "$(cat .devenv/state/pwd)" ]; then
    mkdir -p .devenv/state && pwd >.devenv/state/pwd
fi

use flake ./tools/nix#default \
    --override-input devenv-root "path:.devenv/state/pwd"

This works but devenv up does not work once inside the shell. It cannot find the rootDir because the devenv up tool apparently does not let me specify --override-input devenv-root to the underlying nix command it executes?
I can however run nix build --accept-flake-config --override-input devenv-root "path:.devenv/state/pwd" "./tools/nix#devenv-up" and then ./result.

But whats the right way to do this, or a correct workaround to lunch the processes in such a flake setup?

Would it be possible to add a forwarding of arguments to devenv up to the underlying nix command?Where do I need to look for such an enhancment?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions