Nixos-rebuild switch failed

Hello, I was using flakes to manage my configs but I didnt like suing them so I decided to go back to the old way. I updated my channels using following the documentation guide and when I run

$ sudo nixos-rebuild switch --upgrade

and I get the following error

unpacking channels...
error:
       … while evaluating the attribute 'config'

         at /nix/store/i1aw9jjgxcvyd642s12kw3iasmarwd42-source/lib/modules.nix:322:9:

          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          323|         _module = checked (config._module);

       … while calling the 'seq' builtin

         at /nix/store/i1aw9jjgxcvyd642s12kw3iasmarwd42-source/lib/modules.nix:322:18:

          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          323|         _module = checked (config._module);

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: file 'nixos-config' was not found in the Nix search path (add it using $NIX_PATH or -I)

       at «none»:0: (source not available)
building Nix...
error:
       … while evaluating the attribute 'config'

         at /nix/store/i1aw9jjgxcvyd642s12kw3iasmarwd42-source/lib/modules.nix:322:9:

          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          323|         _module = checked (config._module);

       … while calling the 'seq' builtin

         at /nix/store/i1aw9jjgxcvyd642s12kw3iasmarwd42-source/lib/modules.nix:322:18:

          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          323|         _module = checked (config._module);

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: file 'nixos-config' was not found in the Nix search path (add it using $NIX_PATH or -I)

       at «none»:0: (source not available)
building the system configuration...
error:
       … while evaluating the attribute 'config.system.build.toplevel'

         at /nix/store/i1aw9jjgxcvyd642s12kw3iasmarwd42-source/lib/modules.nix:322:9:

          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          323|         _module = checked (config._module);

       … while calling the 'seq' builtin

         at /nix/store/i1aw9jjgxcvyd642s12kw3iasmarwd42-source/lib/modules.nix:322:18:

          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          323|         _module = checked (config._module);

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: file 'nixos-config' was not found in the Nix search path (add it using $NIX_PATH or -I)

       at «none»:0: (source not available)

I tried using only the config generated by nixos-generate-config and I get the same error. I also tried rebooting the system but that didn’t do anything

Any help will be very appreciated. Thanks

Is your config entry-point located at /etc/nixos/configuration.nix? If not, add -I nixos-config=/path/to/config.nix to the rebuild command.

It was at that path but that fixed it. Thanks!