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

Using directory specific imports when using flakes #271

Open
terlar opened this issue Jan 5, 2023 · 3 comments
Open

Using directory specific imports when using flakes #271

terlar opened this issue Jan 5, 2023 · 3 comments

Comments

@terlar
Copy link

terlar commented Jan 5, 2023

Is it possible to get what is described here:
https://devenv.sh/composing-using-imports/

When using flakes:
https://devenv.sh/guides/using-with-flakes/

Specifically I'm looking for this behavior:

If you enter the frontend directory, the environment will activate based on what's in the frontend/devenv.nix file.

So I could have enterShell defined as well as only have some dependencies on path when entering those directories. Also I would like to have different scripts with same name but activated for different sub folders.

Is this possible? Or are much of the devenv features lost when using flakes? Seems I cannot use the devenv commands for example and the devenv.yaml is ignored. If I run the devenv command it will generate the files and be separate from what is defined in the flake.nix.

@domenkozar
Copy link
Member

Some of the features aren't available in flake mode, one of them is composing environments across directories.

The other one is devenv command support, but that will be improved.

@terlar
Copy link
Author

terlar commented Jan 6, 2023

BTW, I tried switching to devenv without flakes and this is not the behavior I see. What I see is the same behavior as if I did imports = [ ./frontend/devenv.nix ]; inside the root devenv.nix.

I don't see the environment changing if I enter the frontend directory. Or does that need to have a full devenv environment with devenv.yaml, devenv.nix and .envrc as well to get this feature? I guess that would explain things. Since direnv is the thing that loads the environment.

As I did experience this:

If you enter the top-level project, the environment is combined with what's defined in backend/devenv.nix and frontend/devenv.nix. For example, devenv up will start both the frontend and backend processes.

I guess if that is the case none of the top-level stuff will be available in the sub-directory?

@domenkozar
Copy link
Member

You also need .envrc in that folder, that 's something we should mention in the docs.

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

No branches or pull requests

2 participants