Flakes without Git copies entire tree to Nix store

Say I have a directory with some big files. Let’s create a 100 MB file as an example:

$ mkdir flake-test
$ cd flake-test
$ dd if=/dev/zero of=big-file bs=1024 count=100000

Now I want to analyze my data and need some tools for that. Of course I do this using a Nix shell environment. For this I create a new flake.nix:

  description = "big-file";
  outputs = { self, nixpkgs }: let
    system = "x86_64-linux";
  with nixpkgs.legacyPackages.${system};
    devShell.${system} = mkShell {
      buildInputs = [ hello ];

Let’s run nix develop. Hm, this is taking longer than I expected and suddenly my disk usage is going up a lot. What’s happening?

$ find /nix/store -maxdepth 2 -name 'big-file'

Eh, what?

Why did Nix just copy my entire tree to the Nix store? Is there a way to prevent this? (except tracking the directory in Git) It doesn’t happen when I use old nix-shell.

1 Like

There is currently no way to prevent this, see Copy local flakes to the store lazily · Issue #3121 · NixOS/nix · GitHub.

1 Like

Hm, that’s a real bummer. Looks like I’m stuck with nix-shell for now then. At least I can still use flake.nix thanks to your flake-compat.