From 5900b644bb5ed65d162e76a8d084e60197453275 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Wed, 16 Oct 2024 10:47:04 +0200 Subject: [PATCH 1/4] nixos/docker: move live-restore option into daemon.settings Signed-off-by: Sefa Eyeoglu --- nixos/modules/virtualisation/docker.nix | 26 +++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/nixos/modules/virtualisation/docker.nix b/nixos/modules/virtualisation/docker.nix index 4f38bc0b94d6..ed228f76988d 100644 --- a/nixos/modules/virtualisation/docker.nix +++ b/nixos/modules/virtualisation/docker.nix @@ -52,7 +52,19 @@ in daemon.settings = mkOption { - type = settingsFormat.type; + type = types.submodule { + freeformType = settingsFormat.type; + options = { + live-restore = mkOption { + type = types.bool; + default = true; + description = '' + Allow dockerd to be restarted without affecting running container. + This option is incompatible with docker swarm. + ''; + }; + }; + }; default = { }; example = { ipv6 = true; @@ -75,16 +87,6 @@ in ''; }; - liveRestore = - mkOption { - type = types.bool; - default = true; - description = '' - Allow dockerd to be restarted without affecting running container. - This option is incompatible with docker swarm. - ''; - }; - storageDriver = mkOption { type = types.nullOr (types.enum ["aufs" "btrfs" "devicemapper" "overlay" "overlay2" "zfs"]); @@ -253,7 +255,6 @@ in hosts = [ "fd://" ]; log-driver = mkDefault cfg.logDriver; storage-driver = mkIf (cfg.storageDriver != null) (mkDefault cfg.storageDriver); - live-restore = mkDefault cfg.liveRestore; runtimes = mkIf cfg.enableNvidia { nvidia = { # Use the legacy nvidia-container-runtime wrapper to allow @@ -269,6 +270,7 @@ in imports = [ (mkRemovedOptionModule ["virtualisation" "docker" "socketActivation"] "This option was removed and socket activation is now always active") + (mkAliasOptionModule ["virtualisation" "docker" "liveRestore"] ["virtualisation" "docker" "daemon" "settings" "live-restore"]) ]; } From 77a65d189a85c18420d74bad3bc7d1598e2cb331 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Wed, 16 Oct 2024 10:50:05 +0200 Subject: [PATCH 2/4] nixos/docker: keep live-restore disabled by default See https://docs.docker.com/engine/daemon/live-restore/ See https://discourse.nixos.org/t/docker-hanging-on-reboot/18270/5 Closes https://github.com/NixOS/nixpkgs/issues/182916 Signed-off-by: Sefa Eyeoglu --- nixos/doc/manual/release-notes/rl-2411.section.md | 2 ++ nixos/modules/virtualisation/docker.nix | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/nixos/doc/manual/release-notes/rl-2411.section.md b/nixos/doc/manual/release-notes/rl-2411.section.md index 0d1d4059fa88..f71db4fb3df6 100644 --- a/nixos/doc/manual/release-notes/rl-2411.section.md +++ b/nixos/doc/manual/release-notes/rl-2411.section.md @@ -629,6 +629,8 @@ - `lib.misc.mapAttrsFlatten` is now formally deprecated and will be removed in future releases; use the identical [`lib.attrsets.mapAttrsToList`](https://nixos.org/manual/nixpkgs/unstable#function-library-lib.attrsets.mapAttrsToList) instead. +- `virtualisation.docker.liveRestore` has been renamed to `virtualisation.docker.daemon.settings."live-restore"` and turned off by default for state versions of at least 24.11. + - Tailscale's `authKeyFile` can now have its corresponding parameters set through `config.services.tailscale.authKeyParameters`, allowing for non-ephemeral unsupervised deployment and more. See [Registering new nodes using OAuth credentials](https://tailscale.com/kb/1215/oauth-clients#registering-new-nodes-using-oauth-credentials) for the supported options. diff --git a/nixos/modules/virtualisation/docker.nix b/nixos/modules/virtualisation/docker.nix index ed228f76988d..758860279be1 100644 --- a/nixos/modules/virtualisation/docker.nix +++ b/nixos/modules/virtualisation/docker.nix @@ -57,7 +57,10 @@ in options = { live-restore = mkOption { type = types.bool; - default = true; + # Prior to NixOS 24.11, this was set to true by default, while upstream defaulted to false. + # Keep the option unset to follow upstream defaults + default = versionOlder config.system.stateVersion "24.11"; + defaultText = literalExpression "versionOlder config.system.stateVersion \"24.11\""; description = '' Allow dockerd to be restarted without affecting running container. This option is incompatible with docker swarm. @@ -68,6 +71,7 @@ in default = { }; example = { ipv6 = true; + "live-restore" = true; "fixed-cidr-v6" = "fd00::/80"; }; description = '' From 12ba522dfdedde6dc36282ca22d15ac4e1b15649 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sat, 2 Nov 2024 20:15:34 +0100 Subject: [PATCH 3/4] nixos/docker: move imports Signed-off-by: Sefa Eyeoglu --- nixos/modules/virtualisation/docker.nix | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/nixos/modules/virtualisation/docker.nix b/nixos/modules/virtualisation/docker.nix index 758860279be1..456fd77081e2 100644 --- a/nixos/modules/virtualisation/docker.nix +++ b/nixos/modules/virtualisation/docker.nix @@ -173,6 +173,11 @@ in }; }; + imports = [ + (mkRemovedOptionModule ["virtualisation" "docker" "socketActivation"] "This option was removed and socket activation is now always active") + (mkAliasOptionModule ["virtualisation" "docker" "liveRestore"] ["virtualisation" "docker" "daemon" "settings" "live-restore"]) + ]; + ###### implementation config = mkIf cfg.enable (mkMerge [{ @@ -271,10 +276,4 @@ in }; } ]); - - imports = [ - (mkRemovedOptionModule ["virtualisation" "docker" "socketActivation"] "This option was removed and socket activation is now always active") - (mkAliasOptionModule ["virtualisation" "docker" "liveRestore"] ["virtualisation" "docker" "daemon" "settings" "live-restore"]) - ]; - } From a96e4d9bfe337cf7b795658ee7409811094a2196 Mon Sep 17 00:00:00 2001 From: Sandro Date: Tue, 5 Nov 2024 11:23:29 +0100 Subject: [PATCH 4/4] docker: use lib.versionOlder in literalExpression --- nixos/modules/virtualisation/docker.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/virtualisation/docker.nix b/nixos/modules/virtualisation/docker.nix index 456fd77081e2..741828c7468a 100644 --- a/nixos/modules/virtualisation/docker.nix +++ b/nixos/modules/virtualisation/docker.nix @@ -60,7 +60,7 @@ in # Prior to NixOS 24.11, this was set to true by default, while upstream defaulted to false. # Keep the option unset to follow upstream defaults default = versionOlder config.system.stateVersion "24.11"; - defaultText = literalExpression "versionOlder config.system.stateVersion \"24.11\""; + defaultText = literalExpression "lib.versionOlder config.system.stateVersion \"24.11\""; description = '' Allow dockerd to be restarted without affecting running container. This option is incompatible with docker swarm.