# Project environments (flox.nix) without flox init

**URL:** <https://discourse.flox.dev/t/project-environments-flox-nix-without-flox-init/709>\
**Category:** Uncategorized\
**Created:** [March 28, 2023, 8:01pm UTC](https://discourse.flox.dev/t/project-environments-flox-nix-without-flox-init/709 "2023-03-28T20:01:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fleimgruber](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/fleimgruber/32/400_2.png) [@fleimgruber](https://discourse.flox.dev/u/fleimgruber)\
**Post date:** [March 28, 2023, 8:01pm UTC](https://discourse.flox.dev/t/project-environments-flox-nix-without-flox-init/709/1 "2023-03-28T20:01:35Z")

</div>

I was eager to try [flox environments for developers | flox:docs](https://floxdev.com/docs/projects/#floxnix-the-file-where-you-configure-your-flox-environment) as soon as I read the release notes [flox/rl-0.1.2.md at main · flox/flox · GitHub](https://github.com/flox/flox/blob/main/doc/release-notes/rl-0.1.2.md).

I wanted to take this as an opportunity to try to replace the .envrc + default.nix setup for an existing project. I then guessed I would only need a flox.nix file in the top level of the project. I tried that but a `flox activate` activated the default flox environment instead (i.e. it was not respecting the flox.nix file). I then looked at what `flox init ...` does and saw that it also writes a flake.nix file. I then manually created a basic flake.nix file next to the flox.nix file and tried `flox activate`, but again the default environment is activated instead, not the project environment.

When I use `flox init ...` then a `flox activate` does activate the project environment. So as in subject: How to create project environment definition files without `flox init ...` (having the .envrc + default.nix combo in mind)? Am I missing something in the docs or is `flox init ...` the only supported way at the moment?

---

<div class="post-metadata">

**Author:** ![jurraca](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/jurraca/32/397_2.png) [@jurraca](https://discourse.flox.dev/u/jurraca)\
**Post date:** [March 28, 2023, 9:40pm UTC](https://discourse.flox.dev/t/project-environments-flox-nix-without-flox-init/709/2 "2023-03-28T21:40:15Z")

</div>

Hey @fleimgruber ,

We could do better with documentation here, thanks for flagging this. `flox init` is the only way to set up the `flox.nix` automatically at the moment. This will create the flake.nix and flox.nix files. You could then port whatever you had in the `.envrc` and `default.nix` there declaratively (manually) or just run `flox install PACKAGE` and the package will be reflected in your `flox.nix`.

Hope this helps. We’ll update the docs with more detail. Thanks!

---

<div class="post-metadata">

**Author:** ![fleimgruber](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/fleimgruber/32/400_2.png) [@fleimgruber](https://discourse.flox.dev/u/fleimgruber)\
**Post date:** [March 31, 2023, 2:39pm UTC](https://discourse.flox.dev/t/project-environments-flox-nix-without-flox-init/709/3 "2023-03-31T14:39:14Z")

</div>

Hi @jurraca,

thanks for checking back. I was just wondering if `flox init` did something else (e.g. registering the local environment in it’s config somewhere else) apart from creating flox.nix and flake.nix as it did not work when I created those two files manually - with the exact same contents as resulting from a `flox init` done in a different dir.

---

<div class="post-metadata">

**Author:** ![jurraca](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/jurraca/32/397_2.png) [@jurraca](https://discourse.flox.dev/u/jurraca)\
**Post date:** [March 31, 2023, 7:33pm UTC](https://discourse.flox.dev/t/project-environments-flox-nix-without-flox-init/709/4 "2023-03-31T19:33:34Z")

</div>

I see, yes it does create one more directory locally called `.flox/` for the environment. This directory contains symlinks to environment files in the nix store and a shell path setup file. You wouldn’t be able to declare this, and `flox init` takes care of that. Feel free to check out the `.flox/` directory to see what’s created there.

Let me know if I can clarify anything else!

---

<div class="post-metadata">

**Author:** ![fleimgruber](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/fleimgruber/32/400_2.png) [@fleimgruber](https://discourse.flox.dev/u/fleimgruber)\
**Post date:** [March 31, 2023, 8:36pm UTC](https://discourse.flox.dev/t/project-environments-flox-nix-without-flox-init/709/5 "2023-03-31T20:36:01Z")

</div>

Oh, thanks, now I see the .flox/ directory in the test env dir. In my .envrc + default.nix dir after `flox init --template project` only the flox.nix file was created (no flake.nix and no .flox/). `flox activate` still only activates the default env. FWIW, my project dir is an existing git clone. But for me it’s not a real issue, was just curious. Will try again with a newer version.
