Set path for flake.nix file?

I switched to flakes, and now my config files, including flake.nix, live in
I understand that to rebuild, the proper command would be

sudo nixos-rebuild switch --flake .

But it is not finding the flake.nix file, because it says

path '/home/shmuel' does not contain a 'flake.nix', searching up
error: could not find a flake.nix file

It does not seem to be looking up the correct path.

Hey @shmu26 ,

I think you have 2 options.

  1. Run your sudo nixos-rebuild command inside your new flake directory (~/nixos-config): cd ~/nixos-config && sudo nixos-rebuild switch --flake .
  2. Specify the flake directory with the --flake parameter: sudo nixos-rebuild switch --flake ~/nixos-config