Removing profile created by `nix develop --profile`

I was investigating ways to prevent nix develop environments from getting garbage collected, and came across Prevent garbage collection of flake?, which suggested nix develop --profile /path was the way to do it.

However, now I have these read-only files that I apparently can’t remove. Is it sufficient to just sudo rm them? Or is there a nix <command> that I can/should be using instead?

What readonly files?

The command nix develop --profile /path should have created a profile /path and a generation /path-1-link. You may have multiple generations if you had changed some referenced files.

You could remove old generations by nix profile wipe-history --profile /path or you could remove the profile and generations rm /path /path-*-link and then garbage collect paths nix-collect-garbage.

For some reason, my Jetbrains IDE was preventing deletion of the files, complaining about them being “readonly”. I thought it was something special that Nix was doing, but just using rm was sufficient in cleaning things up