image.scm 3.4 KB

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