image.scm 3.4 KB

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