gnu: Remove unneeded uses of 'libiconv'.
[jackhill/guix/guix.git] / gnu / image.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19 (define-module (gnu image)
20 #:use-module (gnu platform)
21 #:use-module (guix records)
22 #:export (partition
23 partition?
24 partition-device
25 partition-size
26 partition-offset
27 partition-file-system
28 partition-file-system-options
29 partition-label
30 partition-uuid
31 partition-flags
32 partition-initializer
33
34 image
35 image?
36 image-name
37 image-format
38 image-platform
39 image-size
40 image-operating-system
41 image-partition-table-type
42 image-partitions
43 image-compression?
44 image-volatile-root?
45 image-shared-store?
46 image-shared-network?
47 image-substitutable?
48
49 image-type
50 image-type?
51 image-type-name
52 image-type-constructor
53
54 os->image
55 os+platform->image))
56
57 \f
58 ;;;
59 ;;; Partition record.
60 ;;;
61
62 (define-record-type* <partition> partition make-partition
63 partition?
64 (device partition-device (default #f))
65 (size partition-size)
66 (offset partition-offset (default 0))
67 (file-system partition-file-system (default "ext4"))
68 (file-system-options partition-file-system-options
69 (default '()))
70 (label partition-label (default #f))
71 (uuid partition-uuid (default #f))
72 (flags partition-flags (default '()))
73 (initializer partition-initializer (default #f)))
74
75 \f
76 ;;;
77 ;;; Image record.
78 ;;;
79
80 (define-record-type* <image>
81 image make-image
82 image?
83 (name image-name ;symbol
84 (default #f))
85 (format image-format) ;symbol
86 (platform image-platform ;<platform>
87 (default #f))
88 (size image-size ;size in bytes as integer
89 (default 'guess))
90 (operating-system image-operating-system ;<operating-system>
91 (default #f))
92 (partition-table-type image-partition-table-type ; 'mbr or 'gpt
93 (default 'mbr))
94 (partitions image-partitions ;list of <partition>
95 (default '()))
96 (compression? image-compression? ;boolean
97 (default #t))
98 (volatile-root? image-volatile-root? ;boolean
99 (default #t))
100 (shared-store? image-shared-store? ;boolean
101 (default #f))
102 (shared-network? image-shared-network? ;boolean
103 (default #f))
104 (substitutable? image-substitutable? ;boolean
105 (default #t)))
106
107 \f
108 ;;;
109 ;;; Image type.
110 ;;;
111
112 (define-record-type* <image-type>
113 image-type make-image-type
114 image-type?
115 (name image-type-name) ;symbol
116 (constructor image-type-constructor)) ;<operating-system> -> <image>
117
118 \f
119 ;;;
120 ;;; Image creation.
121 ;;;
122
123 (define* (os->image os #:key type)
124 (let ((constructor (image-type-constructor type)))
125 (constructor os)))
126
127 (define* (os+platform->image os platform #:key type)
128 (image
129 (inherit (os->image os #:type type))
130 (platform platform)))