executable_guix-git-reset-to-current-channel 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/run/current-system/profile/bin/guile \
  2. --no-auto-compile -e (guix-git-reset-to-current-channel) -s
  3. !#
  4. (define-module (guix-git-reset-to-current-channel)
  5. #:use-module (srfi srfi-1)
  6. #:use-module (guix scripts describe)
  7. #:use-module (guix channels)
  8. #:use-module (ice-9 popen)
  9. #:use-module (ice-9 rdelim)
  10. #:export (guix-git-reset-to-current-channel
  11. main))
  12. (define %home
  13. (and=> (getenv "HOME")
  14. (lambda (home)
  15. home)))
  16. (define (guix-git-reset-to-current-channel)
  17. (define profile (string-append %home "/.config/guix/current"))
  18. (let ((current-guix-channel-commit
  19. (channel-commit
  20. (first
  21. (filter (lambda (channel)
  22. (eq? (channel-name channel) 'guix))
  23. (profile-channels profile)))))
  24. (password
  25. (let* ((port (open-pipe* OPEN_READ "pass" "show" "localhost/ssh/id_rsa_savannah"))
  26. (output (read-string port)))
  27. (close-port port)
  28. (string-trim-right output #\newline))))
  29. (system* "sshpass" "-Ppassphrase" (format #f "-p~a" password)
  30. "git" "fetch" "origin")
  31. (system* "git" "reset" "--hard" current-guix-channel-commit)))
  32. (define (main args)
  33. (guix-git-reset-to-current-channel))