image.scm 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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-partitions
  40. image-compression?
  41. image-volatile-root?
  42. image-substitutable?
  43. image-type
  44. image-type?
  45. image-type-name
  46. image-type-constructor
  47. os->image
  48. os+platform->image))
  49. ;;;
  50. ;;; Partition record.
  51. ;;;
  52. (define-record-type* <partition> partition make-partition
  53. partition?
  54. (device partition-device (default #f))
  55. (size partition-size)
  56. (offset partition-offset (default 0))
  57. (file-system partition-file-system (default "ext4"))
  58. (file-system-options partition-file-system-options
  59. (default '()))
  60. (label partition-label (default #f))
  61. (uuid partition-uuid (default #f))
  62. (flags partition-flags (default '()))
  63. (initializer partition-initializer (default #f)))
  64. ;;;
  65. ;;; Image record.
  66. ;;;
  67. (define-record-type* <image>
  68. image make-image
  69. image?
  70. (name image-name ;symbol
  71. (default #f))
  72. (format image-format) ;symbol
  73. (platform image-platform ;<platform>
  74. (default #f))
  75. (size image-size ;size in bytes as integer
  76. (default 'guess))
  77. (operating-system image-operating-system ;<operating-system>
  78. (default #f))
  79. (partitions image-partitions ;list of <partition>
  80. (default '()))
  81. (compression? image-compression? ;boolean
  82. (default #t))
  83. (volatile-root? image-volatile-root? ;boolean
  84. (default #t))
  85. (substitutable? image-substitutable? ;boolean
  86. (default #t)))
  87. ;;;
  88. ;;; Image type.
  89. ;;;
  90. (define-record-type* <image-type>
  91. image-type make-image-type
  92. image-type?
  93. (name image-type-name) ;symbol
  94. (constructor image-type-constructor)) ;<operating-system> -> <image>
  95. ;;;
  96. ;;; Image creation.
  97. ;;;
  98. (define* (os->image os #:key type)
  99. (let ((constructor (image-type-constructor type)))
  100. (constructor os)))
  101. (define* (os+platform->image os platform #:key type)
  102. (image
  103. (inherit (os->image os #:type type))
  104. (platform platform)))