From f119fac3e4714d07604ee764186d195b20e9ce3b Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 21 Mar 2020 21:51:29 +0000 Subject: Generate two layers for docker images in guix pack Split the store items in to two layers, the top layer with the profile and the store items it directly references, and the bottom layer with the rest of the store items. This means that when you use pack and slightly vary the packages being packed, for example by changing the versions or sources, the base layer will be unchanged. --- guix/scripts/pack.scm | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index a9e9e7a415..698af73d28 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -560,19 +560,31 @@ the image." (docker-image (string-append name ".tar" (compressor-extension compressor)) - (list (docker-image-layer - "pack-docker-image-layer" - (with-store store - (let ((output - (build-derivations store (list profile))) - (path - (derivation-output-path - (match (derivation-outputs profile) - (((name . derivation-output)) - derivation-output))))) - (requisites store (list path)))) - ;;#:extra-files directives - )) + (with-store store + (let* ((output + (build-derivations store (list profile))) + (path + (derivation-output-path + (match (derivation-outputs profile) + (((name . derivation-output)) + derivation-output)))) + (refs + (references store path)) + (reqs + (requisites store (list path)))) + + (list (docker-image-layer + "pack-docker-image-layer" + (sort (filter (lambda (path) + (not (member path refs))) + reqs) + string