(define-module (glicid packages virtualization)
  #:use-module (guix packages)
  #:use-module (guix gexp)
  #:use-module (gnu packages)
  #:use-module (guix utils)
  #:use-module (gnu packages virtualization)
  #:use-module (gnu packages storage)
  #:use-module (guix download)
  #:use-module (glicid utils)
;  #:use-module (glicid packages storage)
)


(define-public qemu-7.0-upstream
  (package
    (inherit qemu)
    (name "qemu-upstream")
    (version "7.0.0")
    (source (origin
      (method url-fetch)
      (uri (string-append "https://download.qemu.org/qemu-" version ".tar.xz"))
      (sha256 (base32 "0fgq8szlc75ymgpxpkj47njqqiw65nxsl2wbg4188whzjp3pbczn"))
      (patches (search-patches
        "qemu-build-info-manual.patch"
        "qemu-fix-agent-paths.patch"
      ))
      (modules '((guix build utils)))
      (snippet
        '(begin
           ;; Delete the bundled meson copy.
           (delete-file-recursively "meson")
        )
      )
    ))
  )
)

(define-public qemu-minimal-7.0-upstream
  (package
    (inherit qemu-minimal)
    (name "qemu-minimal-upstream")
    (version "7.0.0")
    (source (origin
      (method url-fetch)
      (uri (string-append "https://download.qemu.org/qemu-" version ".tar.xz"))
      (sha256 (base32 "0fgq8szlc75ymgpxpkj47njqqiw65nxsl2wbg4188whzjp3pbczn"))
      (patches (search-patches
        "qemu-build-info-manual.patch"
        "qemu-fix-agent-paths.patch"
      ))
      (modules '((guix build utils)))
      (snippet
        '(begin
           ;; Delete the bundled meson copy.
           (delete-file-recursively "meson")
        )
      )
    ))
  )
)

(define local-qemu qemu-7.0-upstream)

(define qemu-latest (latest-version local-qemu qemu))

(define local-qemu-minimal qemu-minimal-7.0-upstream)

(define qemu-minimal-latest (latest-version local-qemu-minimal qemu-minimal))

(define-public qemu-with-rbd
  (package
    (inherit qemu-latest) 
    (name "qemu-with-rbd")
    (arguments
      (substitute-keyword-arguments `(
        #:tests? #f
        ,@(package-arguments qemu)
      ))
    ) 
    (inputs `(
      ("ceph:lib", ceph "lib")
      ,@(package-inputs qemu)
    ))
  )
)

(define-public qemu-minimal-with-rbd
  (package
    (inherit qemu-minimal-latest) 
    (name "qemu-minimal-with-rbd")
    (arguments
      (substitute-keyword-arguments `(
        #:tests? #f
        ,@(package-arguments qemu-minimal)
      ))
    ) 
    (inputs `(
      ("ceph:lib", ceph "lib" )
      ,@(package-inputs qemu-minimal)
    ))
  )
)

(define-public libvirt-8.5
  (package
    (inherit libvirt)
    (name "libvirt")
    (version "8.5.0")
    (source
      (origin
        (method url-fetch)
        (uri (string-append "https://libvirt.org/sources/libvirt-" version ".tar.xz"))
        (sha256 (base32 "0qnvjy7k4l52bb5xylvhm21blkgbhld0jzilhsdf6gdqw6srj7j0"))
        (patches (search-patches "glicid/packages/patches/glicid-libvirt-add-install-prefix.patch"))
      )
    )
  )
)
