From 6d0f174cd9571c49ede89638b8bd8b292f9fc746 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Thu, 8 May 2025 09:56:14 +0200 Subject: [PATCH] Reduce maxLayers to 70 in docker build The nixos/nix docker image is built using `buildLayeredImage`, which spreads the nix store over a configured number of layers. This number was set to create an image with 100 layers. Because there is a limit of (typically) 127 layers in AUFS, this only left 27 layers to build on top. At the same time, nearly half of the created layers were only <100kb in size, many even <10kb, negating the intended advantage in cachability. This commit moves the tradeoff a bit by reducing the number of layers to 70. Layer sizes for the 2.28.3 nixos/nix image: https://hub.docker.com/layers/nixos/nix/2.28.3/images/sha256-d078d7153763895fce17c5fbbdeb86fcfcac414ca0ba875d413c1df57be19931 --- docker.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker.nix b/docker.nix index d52c317d6..a92d478d9 100644 --- a/docker.nix +++ b/docker.nix @@ -7,7 +7,7 @@ channelName ? "nixpkgs", channelURL ? "https://nixos.org/channels/nixpkgs-unstable", extraPkgs ? [ ], - maxLayers ? 100, + maxLayers ? 70, nixConf ? { }, flake-registry ? null, uid ? 0,