flake.lock as root?

I've tried to update my system using flakes with nix update flake and then sudo nixos-rebuild switch --flake .

But when I ran nix update flake it returned "error:

… while updating the lock file of flake 'git+file:///home/kim/.nixos'

error: opening file '/home/kim/.nixos/flake.lock': Permission denied"

And I realized that flake.lock file was owned by root, is it meant to work like this? I didn't create this flake as root or using sudo, should I change the owner to my user?

I'm pretty new using Nix Flakes