Sporadic network issues

Let’s suppose that your ISP DNS service is flaky. This could explain why your mobile connection does not suffer the problem. And, likely your other OSes are configured to overcome it.

One way to overcome it is to bypass your ISP DNS by configuring your device networking to use well-known public DNS servers such as 1.1.1.1, 8.8.8.8, 9.9.9.9 and their IPv6 equivalents. Some network providers try to prevent bypassing their DNS (sometimes at the request of the government). There are ways around that, but it gets complicated.

From your recent post I noticed you use NetworkManager. You can run nmcli to get a summary of how your network interfaces are configured; DNS appears at the end of that output. For instance, mine contains

DNS configuration:
        servers: 10.0.45.1
        domains: lan
        interface: wlp170s0

This indicates that my WiFi connection (wlp170s0) uses server 10.0.45.1 for DNS (among others), which happens to be my home router (and DHCP server). What yours reports will depend on how the various parts of your Internet access are configured.

If your ISP controls your home router (as often is the case) then likely they will have it configured to use their DNS servers. You can use NetworkManager (gui or cli) to override the DNS config and specify a more reliable server. See NetworkManager - ArchWiki.

Much of the ArchWiki info on networking is very deep. Maybe you can find helpful bits by focusing on what talks about client configuration, particularly for DNS and DHCP. You also may find good, desktop-oriented info among the Ubuntu docs.

Assuming your system is configured for DHCP network addressing (very much most common), you may overcome the problem with a simple nixos config change such as adding this to your configuration.nix

networking.networkmanager.insertNameservers = [ "1.1.1.1" "8.8.8.8"];

If you are using IPv6 addressing, then those addresses would be different. I think possibly ["2606:4700:4700::1111" "2606:4700:4700::1001"] would work for IPv6.

An alternative way to deal with a flaky DNS server is to run a local DNS caching service, such as resolved. That is where the resolvectl comes from. It is part of systemd, but many parts of systemd are outside the default OS installation.

Configuring to use resolved is a little more involved. If you want to pursue that path, search for info here in discourse and in the nixos wiki.