What does 'networking.networkmanager.connectionConfig' expect?

I have tried a number of permutations but haven’t found the right one… Can someone tell me what ‘networking.networkmanager.connectionConfig’ expects please?

networking.networkmanager.connectionConfig = {
 	"/org/freedesktop/NetworkManager/Settings/0" = {
 		ipv6 = {
  			method = "disabled";
I have also tried;

“Wired Connection 1”

All of which produce the same error;

error: A definition for option `networking.networkmanager.connectionConfig."/org/freedesktop/NetworkManager/Settings/0"' is not of type `null or boolean or signed integer or string'. Definition values:
 - In `/mnt/etc/nixos/configuration.nix':
 ipv6 = {
 method = "disabled";

I am guessing my error is within ipv6.method = "disabled" which I based on nmcli connection modify "Wired connection 1" ipv6.method "disabled" which works from the console. The valid options listed are [ignore, auto, dhcp, link-local, manual, shared, disabled].

FWIW nmcli connection modify "/org/freedesktop/NetworkManager/Settings/2" ipv6.method "disabled" also works from the command line. (this is slightly confusing given the last number is supposed to be an index value and 1 is the loopback and there are only 2 interfaces in the configuration! :man_shrugging:)

This feels a little heavy handed but it works until I can work out the above…

systemd.services.disable-ipv6 = {
	after = [
	description = "disable-ipv6.service: Run a script to disable IPv6 on Wired Connection 1 using nmcli";
	script = ''
		#!/usr/bin/env bash
		${pkgs.networkmanager}/bin/nmcli connection modify "Wired connection 1" ipv6.method "disabled"
		sleep 1
		${pkgs.networkmanager}/bin/nmcli networking off
		sleep 1
		${pkgs.networkmanager}/bin/nmcli networking on
		exit 0
	serviceConfig = {
		RemainAfterExit = "no";
		Type = "oneshot";
	wantedBy = [

That option is just for settings written to /etc/NetworkManager/NetworkManager.conf in [connection] section.
And it’s a “flat” attrset (lhs is a name, rhs is null/bool/int/string), ie:

networking.networkmanager.connectionConfig = {
    "ethernet.cloned-mac-address" = "preserve";
    "wifi.cloned-mac-address" = "preserve";
    "wifi.powersave" = null;
    "ipv6.method" = "disabled";

If you want to specify separate [connection-...] sections you can probably do it with networking.networkmanager.settings

1 Like

Thanks, that didn’t error during the rebuild but it also didn’t seem to have any effect! :thinking:

networking.networkmanager.connectionConfig = {
	"ipv6.method" = "disabled";

What this seems to do is add the following to /etc/NetworkManager/NetworkManager.conf


I haven’t been able to find out much about what this is supposed to do in this file. I’d sort of expect it to either disable IPv6 altogether which it doesn’t appear to do as interfaces are still showing an IPv6 address even after a service restart. The other option is that ‘new’ connections start with IPv6 disabled which also doesn’t appear to be what actually happens.

The state of IPv6 for an individual connection does seem to be correctly reflected in /etc/NetworkManager/system-connections/<Connection Name>.nmconnection


networking.networkmanager.settings seems to also work on /etc/NetworkManager/NetworkManager.conf so I’m not sure if I can achieve what I want that way.

networking.networkmanager.ensureProfiles.profiles let me declare a new network connection and I can set the IPv6 method in there, but it seems this won’t or can’t edit or replace the default connection that is created and I haven’t found a way to stop it being created yet.

It looks like I could overwrite the existing default file using environment.etc

environment.etc."NetworkManager/system-connections/Wired Connection 1.nmconnection".text = ''

or I can stick to the service I am already using. :man_shrugging: