Commit | Line | Data |
---|---|---|
f19cf27c MO |
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) | |
d5073fd1 | 20 | #:use-module (gnu platform) |
f19cf27c MO |
21 | #:use-module (guix records) |
22 | #:export (partition | |
23 | partition? | |
24 | partition-device | |
25 | partition-size | |
1b4fa785 | 26 | partition-offset |
f19cf27c | 27 | partition-file-system |
bd3716f6 | 28 | partition-file-system-options |
f19cf27c MO |
29 | partition-label |
30 | partition-uuid | |
31 | partition-flags | |
32 | partition-initializer | |
33 | ||
34 | image | |
4cce7610 | 35 | image? |
f19cf27c MO |
36 | image-name |
37 | image-format | |
d5073fd1 | 38 | image-platform |
f19cf27c MO |
39 | image-size |
40 | image-operating-system | |
096a2bf8 | 41 | image-partition-table-type |
f19cf27c MO |
42 | image-partitions |
43 | image-compression? | |
44 | image-volatile-root? | |
594e9428 | 45 | image-shared-store? |
dcc843a7 | 46 | image-shared-network? |
99d036ce MO |
47 | image-substitutable? |
48 | ||
49 | image-type | |
50 | image-type? | |
51 | image-type-name | |
52 | image-type-constructor | |
53 | ||
d5073fd1 MO |
54 | os->image |
55 | os+platform->image)) | |
f19cf27c MO |
56 | |
57 | \f | |
58 | ;;; | |
59 | ;;; Partition record. | |
60 | ;;; | |
61 | ||
62 | (define-record-type* <partition> partition make-partition | |
63 | partition? | |
bd3716f6 MO |
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))) | |
f19cf27c MO |
74 | |
75 | \f | |
76 | ;;; | |
77 | ;;; Image record. | |
78 | ;;; | |
79 | ||
80 | (define-record-type* <image> | |
81 | image make-image | |
82 | image? | |
b904b59c MO |
83 | (name image-name ;symbol |
84 | (default #f)) | |
f19cf27c | 85 | (format image-format) ;symbol |
d5073fd1 | 86 | (platform image-platform ;<platform> |
f292d471 | 87 | (default #f)) |
f19cf27c MO |
88 | (size image-size ;size in bytes as integer |
89 | (default 'guess)) | |
90 | (operating-system image-operating-system ;<operating-system> | |
91 | (default #f)) | |
096a2bf8 RS |
92 | (partition-table-type image-partition-table-type ; 'mbr or 'gpt |
93 | (default 'mbr)) | |
f19cf27c MO |
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)) | |
594e9428 MO |
100 | (shared-store? image-shared-store? ;boolean |
101 | (default #f)) | |
dcc843a7 MO |
102 | (shared-network? image-shared-network? ;boolean |
103 | (default #f)) | |
f19cf27c MO |
104 | (substitutable? image-substitutable? ;boolean |
105 | (default #t))) | |
99d036ce MO |
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))) | |
d5073fd1 MO |
126 | |
127 | (define* (os+platform->image os platform #:key type) | |
128 | (image | |
129 | (inherit (os->image os #:type type)) | |
130 | (platform platform))) |