How to properly setup an environment with Pytorch?

I think it’s config.allowUnfree

import nixpkgs { system = "x86_64-linux"; config.allowUnfree = true; };

see here Allow unfree in flakes

there’s a way via the CLI but you’ll have to pass --impure along with it I think.