guix.scm 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. (use-modules ((guix licenses) #:prefix license:)
  2. (gnu packages base)
  3. (gnu packages bash)
  4. (guix build utils)
  5. (guix build utils)
  6. (guix build-system trivial)
  7. (guix gexp)
  8. (guix gexp)
  9. (guix git-download)
  10. (guix git-download)
  11. (guix packages)
  12. (guix packages)
  13. (ice-9 popen)
  14. (ice-9 rdelim))
  15. (define %source-dir "/home/oleg/.local/share/chezmoi")
  16. (define (git-output . args)
  17. "Execute 'git ARGS ...' command and return its output without trailing
  18. newspace."
  19. (with-directory-excursion %source-dir
  20. (let* ((port (apply open-pipe* OPEN_READ "git" args))
  21. (output (read-string port)))
  22. (close-pipe port)
  23. (string-trim-right output #\newline))))
  24. (define (current-commit)
  25. (git-output "log" "-n" "1" "--pretty=format:%H"))
  26. (let ((commit (current-commit)))
  27. (package
  28. (name "dotfiles")
  29. (version (git-version "2.0.0" "1" (string-take commit 7)))
  30. (source (local-file %source-dir
  31. #:recursive? #t
  32. #:select? (git-predicate %source-dir)))
  33. (build-system trivial-build-system)
  34. (inputs
  35. `(("bash" ,bash)
  36. ("make" ,gnu-make)))
  37. (arguments
  38. `(#:modules ((guix build utils))
  39. #:builder
  40. (begin
  41. (use-modules (guix build utils))
  42. (let ((bin (string-append %output "/bin"))
  43. (dotfiles (string-append %output "/share/dotfiles"))
  44. (executable (string-append %output "/bin/dotfiles")))
  45. (copy-recursively (assoc-ref %build-inputs "source") ".")
  46. (substitute* "bin/executable_dotfiles"
  47. (("@GUIX@") dotfiles)
  48. (("/bin/sh")
  49. (string-append (assoc-ref %build-inputs "bash") "/bin/bash")))
  50. (mkdir-p dotfiles)
  51. (copy-recursively "." dotfiles)
  52. (mkdir-p bin)
  53. (copy-file "bin/executable_dotfiles" executable)
  54. (chmod executable #o555))
  55. #t)))
  56. (home-page "https://github.com/kitnil/dotfiles")
  57. (license license:gpl3+)
  58. (synopsis "WiGust dotfiles")
  59. (description "This package provides wigust dotfiles which could
  60. be installed with chezmoi.")))