I use Systemd units for this.
You need two files to make this work, but once set up, it will work as you want it to. One file will be a .mount file, the other an .automount file. Both should have the same filename where the “/path/to/mount/location” translates to “path-to-mount-location” For example, I have a mount at ~/Games/Emulation. The mount/automount files look like this
home-brent-Games-Emulation.mount
home-brent-Games-Emulation.automount
The contents of each file are as follows.
.mount
[Unit]
Description=Mount Emulation Folder (/home/brent/Games/Emulation)
Requires=network-online.target
After=network-online.target systemd-resolved.service
Wants=network-online.target systemd-resolved.service
[Mount]
What=192.168.1.100:/mnt/Emulation
Where=/home/brent/Games/Emulation
Type=nfs
Options=
[Install]
WantedBy=multi-user.target
The .automount file is a little simpler:
[Unit]
Description=Automount NFS share
[Automount]
Where=/home/brent/Games/Emulation
[Install]
WantedBy=multi-user.target
I use this setup for SMB, but I’ve modified it a little bit for NFS. Just add the NFS mount options you need by the Options= tag in the .mount file. Once complete, move the two files to /etc/systemd/system (You’ll need to do this as sudo) then enable the automount systemd unit with systemctl enable home-brent-Games-Emulation.automount --now
Only one of the two files can be enabled at the same time. If you want the share to automount before being accessed, enable the .mount file. If you want it to automount when accessed, use the .automount file.