;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2020, 2022 Mathieu Othacehe ;;; Copyright © 2023 Oleg Pykhalov ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (gnu image) #:use-module (guix platform) #:use-module (guix records) #:use-module (guix diagnostics) #:use-module (guix i18n) #:use-module (srfi srfi-1) #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) #:export (partition partition? partition-device partition-size partition-offset partition-file-system partition-file-system-options partition-label partition-uuid partition-flags partition-initializer image image? image-name image-format image-platform image-size image-max-layers image-operating-system image-partition-table-type image-partitions image-compression? image-volatile-root? image-shared-store? image-shared-network? image-substitutable? image-type image-type? image-type-name image-type-constructor os->image os+platform->image)) ;;; ;;; Sanitizers. ;;; ;; Image and partition sizes can be either be a size in bytes or the 'guess ;; symbol denoting that the size should be estimated by Guix, according to the ;; image content. (define-with-syntax-properties (validate-size (value properties)) (unless (and value (or (eq? value 'guess) (integer? value))) (raise (make-compound-condition (condition (&error-location (location (source-properties->location properties)))) (formatted-message (G_ "size (~a) can only be 'guess or a numeric expression ~%") value 'field)))) value) ;;; ;;; Partition record. ;;; ;; The partition offset should be a bytes count as an integer. (define-with-syntax-properties (validate-partition-offset (value properties)) (unless (and value (integer? value)) (raise (make-compound-condition (condition (&error-location (location (source-properties->location properties)))) (formatted-message (G_ "the partition offset (~a) can only be a \ numeric expression ~%") value 'field)))) value) ;; The supported partition flags. (define-with-syntax-properties (validate-partition-flags (value properties)) (let ((bad-flags (lset-difference eq? value '(boot esp)))) (unless (and (list? value) (null? bad-flags)) (raise (make-compound-condition (condition (&error-location (location (source-properties->location properties)))) (formatted-message (G_ "unsupported partition flag(s): ~a ~%") bad-flags))))) value) (define-record-type* partition make-partition partition? (size partition-size ;size in bytes as integer or 'guess (default 'guess) (sanitize validate-size)) (offset partition-offset (default 0) ;offset in bytes as integer (sanitize validate-partition-offset)) (file-system partition-file-system (default "ext4")) ;string (file-system-options partition-file-system-options (default '())) ;list of strings (label partition-label) ;string (uuid partition-uuid (default #false)) ; (flags partition-flags (default '()