Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea for pure flakes #1764

Open
yajo opened this issue Mar 10, 2025 · 3 comments
Open

Idea for pure flakes #1764

yajo opened this issue Mar 10, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@yajo
Copy link

yajo commented Mar 10, 2025

I'm being affected by DeterminateSystems/flakehub-push#170.

Of course that's not devenv's fault. However, it made me wonder: why do we need a static value? This is how it's defined:

root = lib.mkOption {
type = types.str;
internal = true;
default = builtins.getEnv "PWD";
};

We can learn from other projects.

devshell uses environmental values from nix shell or direnv if available, and otherwise allows to provide a fallback script that can apply any custom logic that sets their PRJ_ROOT variable.

dream2nix allows setting path.projectRootFile, so that the script traverses the file tree up to finding this file, to find what is considered the project root.

That should let devenv flakes be evaluated purely, while still having a working dev shell with direnv, nix-shell or nix develop.

@yajo yajo added the enhancement New feature or request label Mar 10, 2025
@gabyx

This comment has been minimized.

@sandydoo
Copy link
Member

The long-term solution to this is #1548.

devshell uses environmental values from nix shell or direnv if available, and otherwise allows to provide a fallback script that can apply any custom logic that sets their PRJ_ROOT variable.

This only works for scripts that are executed after enterShell. There is a lot of value in knowing the project root path during the shell build, i.e. inside of Nix.

dream2nix allows setting path.projectRootFile, so that the script traverses the file tree up to finding this file, to find what is considered the project root.

devenv is currently implemented on top of Nix flakes. Flakes are always copied to the store before evaluation, so any path traversal would return the immutable store path. In fact, this root path is exposed as an API within flakes, but it's not useful to us for hooking up local state. What we want instead is the original path to your project.

@yajo
Copy link
Author

yajo commented Mar 12, 2025

There is a lot of value in knowing the project root path during the shell build, i.e. inside of Nix.

Could you give some examples? It'd help understand better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants