anchor.diff:        group = "networkmanager";
       }];
   
  -    services.resolved = lib.mkIf useResolved {
  -      enable = true;
  -    };
  -
       systemd.packages = cfg.packages;
   
       systemd.services."network-manager" = {
         wantedBy = [ "network.target" ];
  -      wants = lib.mkIf useResolved [ "systemd-resolved.service" ];
         restartTriggers = [ configFile ];
   
         preStart = ''
  
positive.code:   # /var/lib/misc is for dnsmasq.leases.
    stateDirs = "/var/lib/NetworkManager /var/lib/dhclient /var/lib/misc";
  
    useDnsmasq = cfg.dns == "dnsmasq";
    useResolved = cfg.dns == "systemd-resolved";
  
    rcman = if useResolved then "unmanaged" else "resolvconf";
  
    configFile = writeText "NetworkManager.conf" ''
      [main]
      plugins=keyfile
      dhcp=${cfg.dhcp}
      dns=${cfg.dns}
      rc-manager=${rcman}
  
      [keyfile]
      ${optionalString (cfg.unmanaged != [])
  
negative.code:         apply = list: (attrValues cfg.basePackages) ++ list;
        };
  
        dhcp = mkOption {
          type = types.enum [ "dhclient" "dhcpcd" "internal" ];
          default = "dhclient";
  