Doing the zero to nix and get a random error

Here with the local flake: 3. Explore Nix development environments

I did the nix flake init and then run nix develop to see:

❯ nix develop                                           
error: getting status of '/nix/store/24w9q8zjcdpfcvv7nvxklkd79h1qrsr7-source/backend/flake.nix': No such file or directory

No idea what’s wrong or what I can do about it.

create an empty directory

I ran it in a non-empty directory and now I see the contents of that directory in the nix store?

You might need to git add the files

Why would I git add the files?

If you are in a git repository, then git needs to be aware of your files, as nix uses git to copy only the relevant files to the store before evaluating the flake.

This is only relevant if you use git and either tell nix explicitly that you use it or rely on the inference mechanisms of nix to detect the flake schema/type.

@NobbZ I’m sure this is helpful but I understand nothing of what you just said.

It doesn’t help that this guide doesn’t really explain anything: 3. Explore Nix development environments

It is.


What are the relevant files?

Why is my project going to the store?

What does that mean?

I didn’t.

No idea that this exists so not sure I can rely on it.

Again: ?

Little bit nicer please? People here answer questions in their own time because they like helping out, no need for sarcastic responses to a reply trying to be helpful. You can just honestly say it’s above your head for now.

That said, taking a step back, nix flakes in general try really hard to provide “reproducibility”, i.e., make sure that if you have the same source everybody building it will be able to get the same results.

As part of ensuring this, nix will copy all files in your project to /nix/store before building, so that each and every path referred to in your nix project has a canonical nix store path to resolve.

This makes lots of features possible, like the evaluation cache. You can find more about it in this issue.

The downside is that nix needs to copy all your files to the nix store. This can be slow, and for that reason, when you use a git repository, nix will only copy the files that git tracks.

This means that any files that git is unaware of (i.e., have never been git add ed before) will not be copied. It’s not enough for the file to show up as untracked when you run git status, it must show up in the unstaged or staged changes (or be in a commit already).

As a side effect, you will also be unable to build any changes not part of the repository yet. This can be nice because you won’t accidentally forget to push a file, resulting in a broken upstream. But it does result in lots of newcomer confusion.

There’s some ongoing work to improve things around this feature too. I don’t think it will solve the tracking problem you have, but it will solve a lot of the other problems this causes. Personally I think the merging of that PR might mark the date when flakes become usable for a general audience.

As for the terminology you’re currently lacking:

All files that your build will at some point try to access

Reading all the .nix files, and figuring out what they mean before running the various tasks you ask nix to do. Similar to compilation, but not compilation, because instead of the output being machine code it’s just essentially instructions for what nix is going to do.

If your flake.nix is in a git repository, nix infers that you’re using git to track your project files, so it turns on the features I described. This can especially trip up people who e.g. put their entire home directory in a git repo, of which there are surprisingly many.

The explicit way of telling nix about your project being in a git repo is by using the git: uri scheme in your inputs to refer to a project. If you use path: instead, nix will skip any git-specific functionality.

Whatever type is set to in the input, see the docs. The uri “scheme” (i.e. the text before :) expands to the type. Hence the “schema/type”, depending on whether you use the uri or the expanded form.

I think “Schema” is the German spelling. Not sure though, schema/scheme have overlapping meanings in English.


“schema” is the spelling used throughout the nix manuals sections about flakes. I just tried to stay consistent with nix terminology.

1 Like

Sorry, I didn’t mean to be glib to above but leaving aside the issue which I don’t think we’re going to figure out here.

nix will only copy the files that git tracks

I’ll check this part out because even though I ran the command in a non-empty directory, all the files there should have been in git.

My desillusionment is I think because I did the Zero to Nix thing and it showed me a bunch of what amounts to really magic tricks but didn’t really explain anything and now I feel dumber than I did before.

A lot of the explanations above feel like:

All told, a monad in X is just a monoid in the category of endofunctors

That classic bit is jargon explicitly designed to be exclusive. Maybe the jargon in Nix doesn’t have the same intention, but the result is the same.

So, I’ll leave off here and continue with the stuff that Amos is writing around Nix which to me is a lot more understandable.

1 Like

Yeah, that’s fair enough. Lots of this stuff is written by folks neck-deep in nix (and devops/haskell/systemd/etc.); it can be hard to know what will trip someone unfamiliar with it up.

Amos’ blog posts are always awesome. You might also have a better time with Xe’s blog.

Very curious what git status gives you, and whether submodules/gitignores are causing you a headache. Seeing the repo tree would help, too.

1 Like

But is the flake.nix that you just newly created in Git? That’s what is not copied to the Nix store according to the original error.

The reason why the tutorial you’re following does not acknowledge Git, is that it suggests working in a new, empty directory, in which case Git is never even in the picture. As mentioned by others:

  • When the flake is in a Git repository, Nix will use Git to identify which files should get copied to the Nix store before building
  • When the flake is not in a Git repository, everything will be copied.
1 Like

That makes sense but I had not gotten at all the notion that it would copy the entire project contents to /nix/store. Whether it copies everything or a selection based on some convention I guess is secondary.

So yeah, that seems to be the issue.

I add the flake.* to git and now nix develop does do something.

In that new shell, I can’t build my project because Security is missing. I add pkgs.darwin.apple_sdk.frameworks.Security to the packages but adding them to buildInputs works too. Now it builds.

What I don’t get though is that buildPhase does not do anything. It just says:
no Makefile, doing nothing

I thought that this was a Rust flake (?)? Shouldn’t buildPhase run cargo?

buildRustPackage uses hooks to overwrite buildPhase, and you can run $buildPhase instead to use that

though you probably just want to run cargo build instead

1 Like