executable_dotfiles-update-commit 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/run/current-system/profile/bin/guile \
  2. --no-auto-compile -e (dotfiles-update-commit) -s
  3. !#
  4. ;;;; guix-latest --- Build Guix system with latest channels.
  5. ;;;; Copyright © 2024 Oleg Pykhalov <go.wigust@gmail.com>
  6. ;;;; Released under the GNU GPLv3 or any later version.
  7. (define-module (dotfiles-update-commit)
  8. #:use-module (gnu system)
  9. #:use-module (guix channels)
  10. #:use-module (guix ci)
  11. #:use-module (guix inferior)
  12. #:use-module (guix profiles)
  13. #:use-module (guix records)
  14. #:use-module (guix scripts pull)
  15. #:use-module (guix store)
  16. #:use-module (guix ui)
  17. #:use-module (ice-9 format)
  18. #:use-module (ice-9 match)
  19. #:use-module (ice-9 popen)
  20. #:use-module (ice-9 pretty-print)
  21. #:use-module (ice-9 rdelim)
  22. #:use-module (srfi srfi-1)
  23. #:use-module (srfi srfi-37)
  24. #:autoload (guix openpgp) (openpgp-format-fingerprint)
  25. #:export (main))
  26. (define (main args)
  27. (let* ((port (open-pipe* OPEN_READ "git" "rev-parse" "HEAD"))
  28. (output (read-string port))
  29. (commit (string-take (string-trim-right output #\newline) 8)))
  30. (close-port port)
  31. (for-each (lambda (file)
  32. (system* "yq" "-y" "-i"
  33. (string-append ".spec.template.metadata.annotations[\"guix-default-channel-commit\"] = \""
  34. commit "\"")
  35. file)
  36. (system* "git" "add" file)
  37. (system* "git" "commit"
  38. (format #f "--message=apps: cluster1: guix: ~a: Update to ~a."
  39. (basename (dirname file))
  40. commit)))
  41. (reverse (append (apply append
  42. (fold (lambda (hostname hostnames)
  43. (cons (list (string-append "/home/oleg/.local/share/chezmoi/apps/cluster1/maintenance-guix-pull-" hostname "/job.yaml")
  44. (string-append "/home/oleg/.local/share/chezmoi/apps/cluster1/maintenance-guix-system-reconfigure-" hostname "/job.yaml")
  45. (string-append "/home/oleg/.local/share/chezmoi/apps/cluster1/maintenance-guix-package-manifest-" hostname "/job.yaml")
  46. (string-append "/home/oleg/.local/share/chezmoi/apps/cluster1/maintenance-guix-home-reconfigure-" hostname "/job.yaml")
  47. (string-append "/home/oleg/.local/share/chezmoi/apps/cluster1/maintenance-nix-home-reconfigure-" hostname "/job.yaml"))
  48. hostnames))
  49. '()
  50. '("kube1" "kube2" "kube3")))
  51. '("/home/oleg/.local/share/chezmoi/apps/cluster1/maintenance-git-dotfiles-kube2/job.yaml")
  52. '("/home/oleg/.local/share/chezmoi/apps/cluster1/maintenance-git-dotfiles-kube3/job.yaml"
  53. "/home/oleg/.local/share/chezmoi/apps/cluster1/maintenance-guix-copy-kube3/job.yaml")
  54. '("/home/oleg/.local/share/chezmoi/apps/cluster1/maintenance-guix-image-workstation/job.yaml"
  55. "/home/oleg/.local/share/chezmoi/apps/cluster1/maintenance-guix-deploy-vm-guix-datavolume/job.yaml"
  56. "/home/oleg/.local/share/chezmoi/apps/cluster1/maintenance-guix-rde-image-workstation/job.yaml")
  57. (apply append
  58. (fold (lambda (hostname hostnames)
  59. (cons (list (string-append "/home/oleg/.local/share/chezmoi/apps/cluster2/maintenance-guix-pull-" hostname "/job.yaml")
  60. (string-append "/home/oleg/.local/share/chezmoi/apps/cluster2/maintenance-guix-system-reconfigure-" hostname "/job.yaml")
  61. (string-append "/home/oleg/.local/share/chezmoi/apps/cluster2/maintenance-guix-package-manifest-" hostname "/job.yaml")
  62. (string-append "/home/oleg/.local/share/chezmoi/apps/cluster2/maintenance-guix-home-reconfigure-" hostname "/job.yaml")
  63. (string-append "/home/oleg/.local/share/chezmoi/apps/cluster2/maintenance-nix-home-reconfigure-" hostname "/job.yaml"))
  64. hostnames))
  65. '()
  66. '("kube5001")))
  67. '("/home/oleg/.local/share/chezmoi/apps/cluster2/maintenance-git-dotfiles-kube5001/job.yaml"))))))