diff --git a/modules/config/networking.nix b/modules/config/networking.nix index 3ea86d2f9cf..5fc06c341ad 100644 --- a/modules/config/networking.nix +++ b/modules/config/networking.nix @@ -3,7 +3,9 @@ {config, pkgs, ...}: with pkgs.lib; + let + cfg = config.networking; options = { @@ -43,7 +45,9 @@ in source = pkgs.writeText "hosts" '' 127.0.0.1 localhost - ::1 localhost + ${optionalString cfg.enableIPv6 '' + ::1 localhost + ''} ${cfg.extraHosts} ''; target = "hosts"; diff --git a/modules/tasks/network-interfaces.nix b/modules/tasks/network-interfaces.nix index 5c984b9e59c..d36a1081de5 100644 --- a/modules/tasks/network-interfaces.nix +++ b/modules/tasks/network-interfaces.nix @@ -278,6 +278,9 @@ in '')} EOF + # Disable or enable IPv6. + echo ${if cfg.enableIPv6 then "0" else "1"} > /proc/sys/net/ipv6/conf/all/disable_ipv6 + # Set the default gateway. ${optionalString (cfg.defaultGateway != "") '' # FIXME: get rid of "|| true" (necessary to make it idempotent).