Mount.nfs: Operation not permitted

I’m on a KVM virtual machine with 3 CPUs and 6G RAM. I installed nixos via the 22.05 KDE Plasma ISO.

I’ve tried several ways of creating NFS mounts in configuration.nix. The code below adds exactly what I need to the fstab.

fileSystems = {
    "/mnt/media" = {
    device = "192.168.1.162:/mnt/media/media";
    mountPoint = "/mnt/media";
    fsType = "nfs";
    options = [ "vers=4" "_netdev" "noauto" "users" "user" "x-systemd.automount" ];
    };
  };

Here is the result of trying to mount it:

[bpeters@nixos:~]$ sudo mount /mnt/media
[sudo] password for bpeters: 
mount.nfs: Operation not permitted

[bpeters@nixos:~]$

Here is the mount point:
Notice that the file mode and ownership is messed up while it is mounted, but if I unmount it, the directory looks good.

[bpeters@nixos:~]$ ls -l /mnt
ls: cannot access '/mnt/media': No such device
total 0
d????????? ? ? ? ?            ? media

[bpeters@nixos:~]$ ls /mnt/media/
ls: cannot access '/mnt/media/': No such device

[bpeters@nixos:~]$ sudo umount /mnt/media

[bpeters@nixos:~]$ ls -l /mnt
total 4
drwxr-xr-x 2 root root 4096 Aug 13 10:50 media

[bpeters@nixos:~]$ ls -l /mnt/media/
total 0

[bpeters@nixos:~]$

Does anyone have a solution for this?

Any help is much appreciated. I’m planning on getting everything working in my VM and then wiping my laptop and using nixos as my daily driver for work.

Thanks,
-Bill

Hi, after two years from your post, I’m struggling with the same issue. Did you find any way to fix it?

I’m using a VM too (in proxmox) and the error happens if I use DHCP, everything ok with static IP.
From boot logs, using DHCP it first correctly wait for network on-line before mounting NFS, but than I get an unexpected network change and I think this affect the mounted nfs share avaiability.

Thanks
Tommaso