image.scm 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. (define-module (gnu image)
  19. #:use-module (gnu platform)
  20. #:use-module (guix records)
  21. #:export (partition
  22. partition?
  23. partition-device
  24. partition-size
  25. partition-offset
  26. partition-file-system
  27. partition-file-system-options
  28. partition-label
  29. partition-uuid
  30. partition-flags
  31. partition-initializer
  32. image
  33. image?
  34. image-name
  35. image-format
  36. image-platform
  37. image-size
  38. image-operating-system
  39. image-partition-table-type
  40. image-partitions
  41. image-compression?
  42. image-volatile-root?
  43. image-shared-store?
  44. image-shared-network?
  45. image-substitutable?
  46. image-type
  47. image-type?
  48. image-type-name
  49. image-type-constructor
  50. os->image
  51. os+platform->image))
  52. ;;;
  53. ;;; Partition record.
  54. ;;;
  55. (define-record-type* <partition> partition make-partition
  56. partition?
  57. (device partition-device (default #f))
  58. (size partition-size)
  59. (offset partition-offset (default 0))
  60. (file-system partition-file-system (default "ext4"))
  61. (file-system-options partition-file-system-options
  62. (default '()))
  63. (label partition-label (default #f))
  64. (uuid partition-uuid (default #f))
  65. (flags partition-flags (default '()))
  66. (initializer partition-initializer (default #f)))
  67. ;;;
  68. ;;; Image record.
  69. ;;;
  70. (define-record-type* <image>
  71. image make-image
  72. image?
  73. (name image-name ;symbol
  74. (default #f))
  75. (format image-format) ;symbol
  76. (platform image-platform ;<platform>
  77. (default #f))
  78. (size image-size ;size in bytes as integer
  79. (default 'guess))
  80. (operating-system image-operating-system ;<operating-system>
  81. (default #f))
  82. (partition-table-type image-partition-table-type ; 'mbr or 'gpt
  83. (default 'mbr))
  84. (partitions image-partitions ;list of <partition>
  85. (default '()))
  86. (compression? image-compression? ;boolean
  87. (default #t))
  88. (volatile-root? image-volatile-root? ;boolean
  89. (default #t))
  90. (shared-store? image-shared-store? ;boolean
  91. (default #f))
  92. (shared-network? image-shared-network? ;boolean
  93. (default #f))
  94. (substitutable? image-substitutable? ;boolean
  95. (default #t)))
  96. ;;;
  97. ;;; Image type.
  98. ;;;
  99. (define-record-type* <image-type>
  100. image-type make-image-type
  101. image-type?
  102. (name image-type-name) ;symbol
  103. (constructor image-type-constructor)) ;<operating-system> -> <image>
  104. ;;;
  105. ;;; Image creation.
  106. ;;;
  107. (define* (os->image os #:key type)
  108. (let ((constructor (image-type-constructor type)))
  109. (constructor os)))
  110. (define* (os+platform->image os platform #:key type)
  111. (image
  112. (inherit (os->image os #:type type))
  113. (platform platform)))