From 59912117d4b8852d9bf5a86dd909f1d4e71b0ad6 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Thu, 16 Dec 2021 08:51:56 +0100 Subject: system: image: Add docker support. * gnu/system/image.scm (docker-image, docker-image-type): New variables. (system-docker-image): New procedure. (image->root-file-system): Add docker image support. (system-image): Ditto. --- gnu/system/image.scm | 125 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 116 insertions(+), 9 deletions(-) (limited to 'gnu/system') diff --git a/gnu/system/image.scm b/gnu/system/image.scm index 4b6aaf2e32..42e215f614 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2020 Mathieu Othacehe +;;; Copyright © 2020, 2021 Mathieu Othacehe ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen ;;; ;;; This file is part of GNU Guix. @@ -36,12 +36,14 @@ #:use-module (gnu services base) #:use-module (gnu system) #:use-module (gnu system file-systems) + #:use-module (gnu system linux-container) #:use-module (gnu system uuid) #:use-module (gnu system vm) #:use-module (guix packages) #:use-module (gnu packages base) #:use-module (gnu packages bootloaders) #:use-module (gnu packages cdrom) + #:use-module (gnu packages compression) #:use-module (gnu packages disk) #:use-module (gnu packages gawk) #:use-module (gnu packages genimage) @@ -67,6 +69,7 @@ efi-disk-image iso9660-image + docker-image raw-with-offset-disk-image image-with-os @@ -74,6 +77,7 @@ qcow2-image-type iso-image-type uncompressed-iso-image-type + docker-image-type raw-with-offset-image-type image-with-label @@ -127,6 +131,10 @@ (label "GUIX_IMAGE") (flags '(boot))))))) +(define docker-image + (image + (format 'docker))) + (define* (raw-with-offset-disk-image #:optional (offset root-offset)) (image (format 'disk-image) @@ -179,6 +187,11 @@ set to the given OS." (compression? #f)) <>)))) +(define docker-image-type + (image-type + (name 'docker) + (constructor (cut image-with-os docker-image <>)))) + (define raw-with-offset-image-type (image-type (name 'raw-with-offset) @@ -220,8 +233,7 @@ set to the given OS." (define-syntax-rule (with-imported-modules* gexp* ...) (with-extensions gcrypt-sqlite3&co (with-imported-modules `(,@(source-module-closure - '((gnu build vm) - (gnu build image) + '((gnu build image) (gnu build bootloader) (gnu build hurd-boot) (gnu build linux-boot) @@ -229,8 +241,7 @@ set to the given OS." #:select? not-config?) ((guix config) => ,(make-config.scm))) #~(begin - (use-modules (gnu build vm) - (gnu build image) + (use-modules (gnu build image) (gnu build bootloader) (gnu build hurd-boot) (gnu build linux-boot) @@ -337,6 +348,8 @@ used in the image." (initializer image-root #:references-graphs '#$graph #:deduplicate? #f + #:copy-closures? (not + #$(image-shared-store? image)) #:system-directory #$os #:grub-efi #+grub-efi #:bootloader-package @@ -527,6 +540,97 @@ returns an image record where the first partition's label is set to