guix.scm 923 B

1234567891011121314151617181920212223242526272829303132
  1. (use-modules
  2. (ice-9 popen)
  3. (ice-9 rdelim)
  4. (guix build utils)
  5. (guix gexp)
  6. (guix git-download)
  7. (guix packages)
  8. (wigust packages dotfiles))
  9. (define %source-dir "/home/oleg/.local/share/chezmoi")
  10. (define (git-output . args)
  11. "Execute 'git ARGS ...' command and return its output without trailing
  12. newspace."
  13. (with-directory-excursion %source-dir
  14. (let* ((port (apply open-pipe* OPEN_READ "git" args))
  15. (output (read-string port)))
  16. (close-pipe port)
  17. (string-trim-right output #\newline))))
  18. (define (current-commit)
  19. (git-output "log" "-n" "1" "--pretty=format:%H"))
  20. (let ((commit (current-commit)))
  21. (package
  22. (inherit dotfiles)
  23. (version (string-append (package-version dotfiles)
  24. "-" (string-take commit 7)))
  25. (source (local-file %source-dir
  26. #:recursive? #t
  27. #:select? (git-predicate %source-dir)))))