mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2025-01-18 21:46:35 +01:00
system: image: Add wsl2 support.
* gnu/image.scm (<image>)[format]: Add wsl2 support. * gnu/system/image.scm (wsl2-image, wsl2-image-type): New variables. (image->root-file-system): Add wsl2 image support. (system-image): Ditto.
This commit is contained in:
parent
8757c3f293
commit
233cf9f036
2 changed files with 35 additions and 4 deletions
|
@ -152,7 +152,7 @@ (define-with-syntax-properties (name (value properties))
|
||||||
|
|
||||||
;; The supported image formats.
|
;; The supported image formats.
|
||||||
(define-set-sanitizer validate-image-format format
|
(define-set-sanitizer validate-image-format format
|
||||||
(disk-image compressed-qcow2 docker iso9660 tarball))
|
(disk-image compressed-qcow2 docker iso9660 tarball wsl2))
|
||||||
|
|
||||||
;; The supported partition table types.
|
;; The supported partition table types.
|
||||||
(define-set-sanitizer validate-partition-table-type partition-table-type
|
(define-set-sanitizer validate-partition-table-type partition-table-type
|
||||||
|
|
|
@ -39,12 +39,14 @@ (define-module (gnu system image)
|
||||||
#:use-module (gnu services)
|
#:use-module (gnu services)
|
||||||
#:use-module (gnu services base)
|
#:use-module (gnu services base)
|
||||||
#:use-module (gnu system)
|
#:use-module (gnu system)
|
||||||
|
#:use-module (gnu system accounts)
|
||||||
#:use-module (gnu system file-systems)
|
#:use-module (gnu system file-systems)
|
||||||
#:use-module (gnu system linux-container)
|
#:use-module (gnu system linux-container)
|
||||||
#:use-module (gnu system uuid)
|
#:use-module (gnu system uuid)
|
||||||
#:use-module (gnu system vm)
|
#:use-module (gnu system vm)
|
||||||
#:use-module (guix packages)
|
#:use-module (guix packages)
|
||||||
#:use-module (gnu packages base)
|
#:use-module (gnu packages base)
|
||||||
|
#:use-module (gnu packages bash)
|
||||||
#:use-module (gnu packages bootloaders)
|
#:use-module (gnu packages bootloaders)
|
||||||
#:use-module (gnu packages cdrom)
|
#:use-module (gnu packages cdrom)
|
||||||
#:use-module (gnu packages compression)
|
#:use-module (gnu packages compression)
|
||||||
|
@ -77,6 +79,7 @@ (define-module (gnu system image)
|
||||||
iso9660-image
|
iso9660-image
|
||||||
docker-image
|
docker-image
|
||||||
tarball-image
|
tarball-image
|
||||||
|
wsl2-image
|
||||||
raw-with-offset-disk-image
|
raw-with-offset-disk-image
|
||||||
|
|
||||||
image-with-os
|
image-with-os
|
||||||
|
@ -87,6 +90,7 @@ (define-module (gnu system image)
|
||||||
uncompressed-iso-image-type
|
uncompressed-iso-image-type
|
||||||
docker-image-type
|
docker-image-type
|
||||||
tarball-image-type
|
tarball-image-type
|
||||||
|
wsl2-image-type
|
||||||
raw-with-offset-image-type
|
raw-with-offset-image-type
|
||||||
|
|
||||||
image-with-label
|
image-with-label
|
||||||
|
@ -164,6 +168,10 @@ (define tarball-image
|
||||||
(image-without-os
|
(image-without-os
|
||||||
(format 'tarball)))
|
(format 'tarball)))
|
||||||
|
|
||||||
|
(define wsl2-image
|
||||||
|
(image-without-os
|
||||||
|
(format 'wsl2)))
|
||||||
|
|
||||||
(define* (raw-with-offset-disk-image #:optional (offset root-offset))
|
(define* (raw-with-offset-disk-image #:optional (offset root-offset))
|
||||||
(image-without-os
|
(image-without-os
|
||||||
(format 'disk-image)
|
(format 'disk-image)
|
||||||
|
@ -231,6 +239,11 @@ (define tarball-image-type
|
||||||
(name 'tarball)
|
(name 'tarball)
|
||||||
(constructor (cut image-with-os tarball-image <>))))
|
(constructor (cut image-with-os tarball-image <>))))
|
||||||
|
|
||||||
|
(define wsl2-image-type
|
||||||
|
(image-type
|
||||||
|
(name 'wsl2)
|
||||||
|
(constructor (cut image-with-os wsl2-image <>))))
|
||||||
|
|
||||||
(define raw-with-offset-image-type
|
(define raw-with-offset-image-type
|
||||||
(image-type
|
(image-type
|
||||||
(name 'raw-with-offset)
|
(name 'raw-with-offset)
|
||||||
|
@ -709,7 +722,8 @@ (define builder
|
||||||
(define* (system-tarball-image image
|
(define* (system-tarball-image image
|
||||||
#:key
|
#:key
|
||||||
(name "image")
|
(name "image")
|
||||||
(compressor (srfi-1:first %compressors)))
|
(compressor (srfi-1:first %compressors))
|
||||||
|
(wsl? #f))
|
||||||
"Build a tarball of IMAGE. NAME is the base name to use for the
|
"Build a tarball of IMAGE. NAME is the base name to use for the
|
||||||
output file."
|
output file."
|
||||||
(let* ((os (image-operating-system image))
|
(let* ((os (image-operating-system image))
|
||||||
|
@ -717,7 +731,12 @@ (define* (system-tarball-image image
|
||||||
(schema (local-file (search-path %load-path
|
(schema (local-file (search-path %load-path
|
||||||
"guix/store/schema.sql")))
|
"guix/store/schema.sql")))
|
||||||
(name (string-append name ".tar" (compressor-extension compressor)))
|
(name (string-append name ".tar" (compressor-extension compressor)))
|
||||||
(graph "system-graph"))
|
(graph "system-graph")
|
||||||
|
(root (srfi-1:find (lambda (user)
|
||||||
|
(and=> (user-account-uid user) zero?))
|
||||||
|
(operating-system-users os)))
|
||||||
|
(root-shell (or (and=> root user-account-shell)
|
||||||
|
(file-append bash "/bin/bash"))))
|
||||||
(define builder
|
(define builder
|
||||||
(with-extensions gcrypt-sqlite3&co ;for (guix store database)
|
(with-extensions gcrypt-sqlite3&co ;for (guix store database)
|
||||||
(with-imported-modules `(,@(source-module-closure
|
(with-imported-modules `(,@(source-module-closure
|
||||||
|
@ -753,6 +772,16 @@ (define builder
|
||||||
#:system-directory #$os)
|
#:system-directory #$os)
|
||||||
|
|
||||||
(with-directory-excursion image-root
|
(with-directory-excursion image-root
|
||||||
|
#$@(if wsl?
|
||||||
|
#~(;; WSL requires /bin/sh. Will be overwritten by
|
||||||
|
;; system activation.
|
||||||
|
(symlink #$root-shell "./bin/sh")
|
||||||
|
|
||||||
|
;; WSL requires /bin/mount to access the host fs.
|
||||||
|
(symlink #$(file-append util-linux "/bin/mount")
|
||||||
|
"./bin/mount"))
|
||||||
|
#~())
|
||||||
|
|
||||||
(apply invoke tar "-cvf" #$output "."
|
(apply invoke tar "-cvf" #$output "."
|
||||||
(tar-base-options
|
(tar-base-options
|
||||||
#:tar tar
|
#:tar tar
|
||||||
|
@ -775,7 +804,7 @@ (define (image->root-file-system image)
|
||||||
"Return the IMAGE root partition file-system type."
|
"Return the IMAGE root partition file-system type."
|
||||||
(case (image-format image)
|
(case (image-format image)
|
||||||
((iso9660) "iso9660")
|
((iso9660) "iso9660")
|
||||||
((docker tarball) "dummy")
|
((docker tarball wsl2) "dummy")
|
||||||
(else
|
(else
|
||||||
(partition-file-system (find-root-partition image)))))
|
(partition-file-system (find-root-partition image)))))
|
||||||
|
|
||||||
|
@ -914,6 +943,8 @@ (define target (cond
|
||||||
(system-docker-image image*))
|
(system-docker-image image*))
|
||||||
((memq image-format '(tarball))
|
((memq image-format '(tarball))
|
||||||
(system-tarball-image image*))
|
(system-tarball-image image*))
|
||||||
|
((memq image-format '(wsl2))
|
||||||
|
(system-tarball-image image* #:wsl? #t))
|
||||||
((memq image-format '(iso9660))
|
((memq image-format '(iso9660))
|
||||||
(system-iso9660-image
|
(system-iso9660-image
|
||||||
image*
|
image*
|
||||||
|
|
Loading…
Reference in a new issue