Is using the `./.` directory in flakes still an antipattern?

The linked page says it’s bad because the name given to the path in the nix store isn’t controlled, so the hash differs. This isn’t a problem in nix since it’s always named ...-source anyway. But using ./. is still likely to copy the directory an extra time into the nix store.

{
  outputs = { ... }: {
    foo = "${./.}";
  };
}

$ nix eval .#foo
"/nix/store/blrp8010cjvs8kv4jngvgj3fc6g5rvxc-dnpq4ndp6j41asnl6h5ylnl6hw7vyks3-source"

compared to:

{
  outputs = { self }: {
    foo = "${self}";
  };
}

$ nix eval .#foo
"/nix/store/xy6bd1cch2c36i8y3d4rqa1kqw4zpn6n-source"

Notice the double hash in the name in the first version. Nix copied the flake into the store and eval’d code from there. When it referenced ./., it copied the directory back into the store again.

3 Likes