# Flakes efficient usage / setup - ad-hoc environments

**URL:** https://discourse.nixos.org/t/flakes-efficient-usage-setup-ad-hoc-environments/13046
**Category:** Help
**Created:** [May 13, 2021, 9:28am UTC](https://discourse.nixos.org/t/flakes-efficient-usage-setup-ad-hoc-environments/13046 "2021-05-13T09:28:00Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![igel](https://discourse.nixos.org/user_avatar/discourse.nixos.org/igel/32/3964_2.png) [@igel](https://discourse.nixos.org/u/igel)
#### Post date: [May 13, 2021, 9:28am UTC](https://discourse.nixos.org/t/flakes-efficient-usage-setup-ad-hoc-environments/13046/1 "2021-05-13T09:28:00Z")

</div>

instead of (used with legacy) `nix-shell`  
with `nixFlakes` concepts/commands

- the/a file in a (more or less clean) directory has to be named “flake.nix”? - `is not a flake (because it doesn't contain a 'flake.nix' file)`  
– means implicit that meaningful/semantic naming can only be done via the directory name?
- it is not possible to call a specific file with an arbitrarily name `*.nix`?
- it not possible to have more than `one` flake.nix in a directory?
- it cannot be used without the file been added via git (outside of a git context)?

---

<div class="post-metadata">

### Author: ![NobbZ](https://discourse.nixos.org/user_avatar/discourse.nixos.org/nobbz/32/7022_2.png) [@NobbZ](https://discourse.nixos.org/u/NobbZ)
#### Post date: [May 13, 2021, 11:27am UTC](https://discourse.nixos.org/t/flakes-efficient-usage-setup-ad-hoc-environments/13046/2 "2021-05-13T11:27:39Z")

</div>

1. The `flake.nix` is the entrypoint to the _project_, it makes sense to have a single common name for it.
2. Not sure what you mean by “call a specific file”, files are commonly read or written to, but not “called”.
3. Of course not. You can not have multiple files with the same name in a single directory, though in my opinion, having many projects in a single directory isn’t something you usually do anyways
4. Sadly yes. If your project is under a version controll that is supported by flakes, you have to add the `flake.nix` and the `flake.lock` under version control. Of all the mentioned things in your post I consider this the only actual limitation of flakes…

---

<div class="post-metadata">

### Author: ![igel](https://discourse.nixos.org/user_avatar/discourse.nixos.org/igel/32/3964_2.png) [@igel](https://discourse.nixos.org/u/igel)
#### Post date: [May 13, 2021, 12:31pm UTC](https://discourse.nixos.org/t/flakes-efficient-usage-setup-ad-hoc-environments/13046/3 "2021-05-13T12:31:01Z")

</div>

your view a project based (where you know what and how you want to build up your idea) - `stage 2`

What I’m referring to is - `stage 1` - an ad-hoc/dynamic environment where you test (and switch back and forth) out very different technologies and ways to get a fitting direction for the project

In my point of view those two states someone goes through while creating something new (perhaps complex) has quite different requirements (and flakes looks like [only] focused on the second stage at the moment)

* * *

nix-shell is not limited to `shell.nix` or default.nix (`nix-shell hello_xy.nix` works fine, right?)

In e.g. vscode I have \> 5 flake.nix files open (so that I always have to get the path [which has to be short not shorten the tab itself …] not the file name …)

- with nix-shell and proper file names that was very clear (with short tabs [individual file naming → not path added in the tab itself] … )

* * *

I don’t want to discuss about (good or bad) flakes here!  
I would like to get to know if there are any workarounds to use flakes as it would be efficient for my work (and if not, I have to write some scripts to automate the boilerplate and arrange a new logic of handling the initial phase)

---

<div class="post-metadata">

### Author: ![brogos](https://discourse.nixos.org/user_avatar/discourse.nixos.org/brogos/32/2660_2.png) [@brogos](https://discourse.nixos.org/u/brogos)
#### Post date: [May 14, 2021, 1:18am UTC](https://discourse.nixos.org/t/flakes-efficient-usage-setup-ad-hoc-environments/13046/4 "2021-05-14T01:18:55Z")

</div>

> [@NobbZ](#):
>
> Sadly yes. If your project is under a version controll that is supported by flakes, you have to add the `flake.nix` and the `flake.lock` under version control. Of all the mentioned things in your post I consider this the only actual limitation of flakes…

It’s not necessary to add `flake.nix` under version control, just add `path:$PWD` to your nix call, like this:

```auto
nix develop path:$PWD

```
