guix-helper.scm 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. (use-modules (zenity))
  2. (let* ((info (or (zenity-forms "Guix Package Helper"
  3. "Package information:"
  4. '((entry . "package name")
  5. (entry . "version")
  6. (entry . "source code url")
  7. (entry . "[git commit id]")
  8. (entry . "synopsis")
  9. (entry . "home page")))
  10. (exit)))
  11. (package-name (list-ref info 0))
  12. (version (list-ref info 1))
  13. (source-url (list-ref info 2))
  14. (commit (list-ref info 3))
  15. (synopsis (list-ref info 4))
  16. (home-page (list-ref info 5))
  17. (method (if (equal? commit "")
  18. 'url-fetch
  19. 'git-fetch))
  20. (inputs (or (zenity-entry "List some of the inputs (separated by a space):")
  21. #f))
  22. (license (or (zenity-list "Guix Package Helper"
  23. '("License")
  24. (map list
  25. '("gpl1" "gpl1+" "gpl2" "gpl2+" "gpl3" "gpl3+"
  26. "bsd-2" "bsd-3" "bsd-4"
  27. "x11" "x11-style"
  28. "non-copyleft" "unlicense"))
  29. #:height 400)
  30. (exit)))
  31. (build-system/tests (or (zenity-list "Guix Package Helper"
  32. '("Build System")
  33. (map list
  34. '("trivial-build-system (no tests)"
  35. "gnu-build-system"
  36. "gnu-build-system (disable tests)"
  37. "cmake-build-system"
  38. "cmake-build-system (disable tests)"))
  39. #:height 400)
  40. (exit)))
  41. (build-system (string-split (car build-system/tests) #\space))
  42. (tests? (not (string-index (car build-system/tests) #\space))))
  43. (newline)
  44. (format #t "(define-public ~a~%" package-name)
  45. (format #t " (package~%")
  46. (format #t " (name ~s)~%" package-name)
  47. (format #t " (version ~s)~%" version)
  48. (format #t " (source (origin~%")
  49. (format #t " (method ~a)~%" method)
  50. (case method
  51. ((url-fetch)
  52. (format #t " (uri ~s)~%" source-url))
  53. ((git-fetch)
  54. (format #t " (uri (git-reference~%")
  55. (format #t " (url ~s)~%" source-url)
  56. (format #t " (commit ~s))~%" commit)))
  57. (format #t " (sha256~%")
  58. (format #t " (base32~%")
  59. (format #t " ~s))))~%" "")
  60. (format #t " (build-system ~a)~%" (car build-system))
  61. (unless tests?
  62. (format #t " (arguments~%")
  63. (format #t " `(#:tests? #f))~%"))
  64. (when inputs
  65. (format #t " (inputs~%")
  66. (let ((indent " `("))
  67. (for-each (lambda (input)
  68. (format #t "~a(~s ,~a)~%" indent input input)
  69. (set! indent " "))
  70. (string-split inputs #\space))
  71. (format #t "~a))~%" indent)))
  72. (format #t " (synopsis ~s)~%" synopsis)
  73. (format #t " (description ~s)~%" "TODO")
  74. (format #t " (home-page ~s)~%" home-page)
  75. (format #t " (license ~a)))~%" (string-append "license:" (car license)))
  76. (newline)
  77. (exit))