From 332e0e927deca31452cc53332c7568bade2bff8b Mon Sep 17 00:00:00 2001 From: Fredholm <41293039+HolmDev@users.noreply.github.com> Date: Tue, 30 Dec 2025 22:46:14 +0100 Subject: [PATCH] Add enableFakechroot option for image generation --- src/nix/modules/service/image.nix | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/nix/modules/service/image.nix b/src/nix/modules/service/image.nix index ae5d214..bfeeb2b 100644 --- a/src/nix/modules/service/image.nix +++ b/src/nix/modules/service/image.nix @@ -30,7 +30,7 @@ let { name = null; tag = null; contents = null; config = null; created = null; extraCommands = null; maxLayers = null; - fakeRootCommands = null; + fakeRootCommands = null; enableFakechroot = null; } args; acceptedArgs = functionArgs dockerTools.streamLayeredImage; @@ -50,6 +50,8 @@ let name contents includeStorePaths + fakeRootCommands + enableFakechroot ; config = config.image.rawConfig; maxLayers = 100; @@ -68,8 +70,6 @@ let ln -s $i nix/var/nix/gcroots/docker/$(basename $i) done; ''; - - fakeRootCommands = config.image.fakeRootCommands; }; priorityIsDefault = option: option.highestPrio >= (lib.mkDefault true).priority; @@ -132,6 +132,15 @@ in See [`dockerTools.buildLayeredImage`](https://nixos.org/manual/nixpkgs/stable/#ssec-pkgs-dockerTools-buildLayeredImage). ''; }; + image.enableFakechroot = mkOption { + type = bool; + default = false; + description = '' + Runs the commands from `image.fakeRootCommands` in a complete fakechroot environment instead of fakeroot. This allows installation in `/` to work as expected, similar to the instruction [`RUN`](https://docs.docker.com/reference/dockerfile/#run). + + See [`dockerTools.buildLayeredImage`](https://nixos.org/manual/nixpkgs/stable/#ssec-pkgs-dockerTools-buildLayeredImage). + ''; + }; image.includeStorePaths = mkOption { type = bool; default = true;