Nix develop flake not working in git project

I have the following flake.nix:

  description = "mkdocs";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";

  outputs = { self , nixpkgs ,... }:
    system = "x86_64-linux";
  in {
    devShells."${system}".default =
      pkgs = import nixpkgs {
        inherit system;
    in pkgs.mkShell {
      packages = with pkgs; [ 

it works when executing nix develop in an empty directory however when I run it in a seperate git directory I get the following error:

(.venv) kunruh@thinkfreax ~/s/Hephaestus-Energy-Forge (main)> nix flake lock
warning: Git tree '/home/kunruh/src/Hephaestus-Energy-Forge' is dirty
error: getting status of '/nix/store/kmng3arqw687b4k6cqf3mx3kdy8jsv5k-source/flake.nix': No such file or directory
(.venv) kunruh@thinkfreax ~/s/Hephaestus-Energy-Forge (main) [0|1]>

I am new to nix so can someone help me with what I am missing?

Flakes require that all your files are at least git add-ed, because they end up copying every file known by git to /nix/store before starting the build.

If your flake.nix is not yet known to git, you get that error.

1 Like