Merge pull request #141549 from bobvanderlinden/docker-daemon-config

nixos/docker: add daemon.settings option

authored by Robert Hensing and committed by GitHub f0fe5e9b e0e8ca98

+40 -7
+8
nixos/doc/manual/from_md/release-notes/rl-2205.section.xml
··· 109 <literal>writers.writePyPy2</literal> needs to be used. 110 </para> 111 </listitem> 112 </itemizedlist> 113 </section> 114 <section xml:id="sec-release-22.05-notable-changes">
··· 109 <literal>writers.writePyPy2</literal> needs to be used. 110 </para> 111 </listitem> 112 + <listitem> 113 + <para> 114 + If you previously used 115 + <literal>/etc/docker/daemon.json</literal>, you need to 116 + incorporate the changes into the new option 117 + <literal>virtualisation.docker.daemon.settings</literal>. 118 + </para> 119 + </listitem> 120 </itemizedlist> 121 </section> 122 <section xml:id="sec-release-22.05-notable-changes">
+2
nixos/doc/manual/release-notes/rl-2205.section.md
··· 41 - The `writers.writePython2` and corresponding `writers.writePython2Bin` convenience functions to create executable Python 2 scripts in the store were removed in preparation of removal of the Python 2 interpreter. 42 Scripts have to be converted to Python 3 for use with `writers.writePython3` or `writers.writePyPy2` needs to be used. 43 44 ## Other Notable Changes {#sec-release-22.05-notable-changes} 45 46 - The option [services.redis.servers](#opt-services.redis.servers) was added
··· 41 - The `writers.writePython2` and corresponding `writers.writePython2Bin` convenience functions to create executable Python 2 scripts in the store were removed in preparation of removal of the Python 2 interpreter. 42 Scripts have to be converted to Python 3 for use with `writers.writePython3` or `writers.writePyPy2` needs to be used. 43 44 + - If you previously used `/etc/docker/daemon.json`, you need to incorporate the changes into the new option `virtualisation.docker.daemon.settings`. 45 + 46 ## Other Notable Changes {#sec-release-22.05-notable-changes} 47 48 - The option [services.redis.servers](#opt-services.redis.servers) was added
+30 -7
nixos/modules/virtualisation/docker.nix
··· 8 9 cfg = config.virtualisation.docker; 10 proxy_env = config.networking.proxy.envVars; 11 - 12 in 13 14 { ··· 50 <literal>--restart=always</literal> flag to work. If this option is 51 disabled, docker might be started on demand by socket activation. 52 ''; 53 }; 54 55 enableNvidia = ··· 171 "" 172 '' 173 ${cfg.package}/bin/dockerd \ 174 - --group=docker \ 175 - --host=fd:// \ 176 - --log-driver=${cfg.logDriver} \ 177 - ${optionalString (cfg.storageDriver != null) "--storage-driver=${cfg.storageDriver}"} \ 178 - ${optionalString cfg.liveRestore "--live-restore" } \ 179 - ${optionalString cfg.enableNvidia "--add-runtime nvidia=${pkgs.nvidia-docker}/bin/nvidia-container-runtime" } \ 180 ${cfg.extraOptions} 181 '']; 182 ExecReload=[ ··· 219 { assertion = cfg.enableNvidia -> config.hardware.opengl.driSupport32Bit or false; 220 message = "Option enableNvidia requires 32bit support libraries"; 221 }]; 222 } 223 ]); 224
··· 8 9 cfg = config.virtualisation.docker; 10 proxy_env = config.networking.proxy.envVars; 11 + settingsFormat = pkgs.formats.json {}; 12 + daemonSettingsFile = settingsFormat.generate "daemon.json" cfg.daemon.settings; 13 in 14 15 { ··· 51 <literal>--restart=always</literal> flag to work. If this option is 52 disabled, docker might be started on demand by socket activation. 53 ''; 54 + }; 55 + 56 + daemon.settings = 57 + mkOption { 58 + type = settingsFormat.type; 59 + default = { }; 60 + example = { 61 + ipv6 = true; 62 + "fixed-cidr-v6" = "fd00::/80"; 63 + }; 64 + description = '' 65 + Configuration for docker daemon. The attributes are serialized to JSON used as daemon.conf. 66 + See https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file 67 + ''; 68 }; 69 70 enableNvidia = ··· 186 "" 187 '' 188 ${cfg.package}/bin/dockerd \ 189 + --config-file=${daemonSettingsFile} \ 190 ${cfg.extraOptions} 191 '']; 192 ExecReload=[ ··· 229 { assertion = cfg.enableNvidia -> config.hardware.opengl.driSupport32Bit or false; 230 message = "Option enableNvidia requires 32bit support libraries"; 231 }]; 232 + 233 + virtualisation.docker.daemon.settings = { 234 + group = "docker"; 235 + hosts = [ "fd://" ]; 236 + log-driver = mkDefault cfg.logDriver; 237 + storage-driver = mkIf (cfg.storageDriver != null) (mkDefault cfg.storageDriver); 238 + live-restore = mkDefault cfg.liveRestore; 239 + runtimes = mkIf cfg.enableNvidia { 240 + nvidia = { 241 + path = "${pkgs.nvidia-docker}/bin/nvidia-container-runtime"; 242 + }; 243 + }; 244 + }; 245 } 246 ]); 247