update commits, fix hyprland ambiguous, fix update-commits script to get timestamps correctly

This commit is contained in:
Murphy 2024-12-09 09:13:59 -05:00
parent 7ab26f7212
commit 2a6a04b6ae
Signed by: freya
GPG key ID: 9FBC6FFD6D2DBF17
6 changed files with 67 additions and 38 deletions

View file

@ -3,7 +3,7 @@
(url "https://git.savannah.gnu.org/git/guix.git") (url "https://git.savannah.gnu.org/git/guix.git")
(branch "master") (branch "master")
(commit (commit
"c56505e399834a3f68cf2b6715b42f12ceea217a") "9d09b0cf841fb657a1aec12e9bab68e00c2b493c")
(introduction (introduction
(make-channel-introduction (make-channel-introduction
"9edb3f66fd807b096b48283debdcddccfea34bad" "9edb3f66fd807b096b48283debdcddccfea34bad"
@ -14,7 +14,7 @@
(url "https://gitlab.com/nonguix/nonguix.git") (url "https://gitlab.com/nonguix/nonguix.git")
(branch "master") (branch "master")
(commit (commit
"720df79727769e4230706e891841ec6f0b8b3890") "4aa03a3ccf6bb693bd4c99900bcd81845c249bbe")
(introduction (introduction
(make-channel-introduction (make-channel-introduction
"897c1a470da759236cc11798f4e0a5f7d4d59fbc" "897c1a470da759236cc11798f4e0a5f7d4d59fbc"

View file

@ -20,6 +20,7 @@
(sakura home services pipewire) (sakura home services pipewire)
(sakura packages gnome-xyz) (sakura packages gnome-xyz)
(sakura packages sound) (sakura packages sound)
(sakura packages hypr)
(sakura packages vim)) (sakura packages vim))
@ -34,7 +35,6 @@
"swaylock-effects" "swaylock-effects"
; hyprland ; hyprland
"hyprland"
"hyprlock" "hyprlock"
"hyprpaper" "hyprpaper"
"hypridle" "hypridle"
@ -141,6 +141,7 @@
; add ca certs and ambiguous packages ; add ca certs and ambiguous packages
(list freya-ca-certs (list freya-ca-certs
hyprland
orchis-theme-2024 orchis-theme-2024
blueman-sakura))) blueman-sakura)))

21
scripts/guix-retry Executable file
View file

@ -0,0 +1,21 @@
#!/bin/sh
error="write_to_session_record_port"
# create redirection
# file descripters
exec 11>&1 # stdout
exec 22>&2 # stderr
while true; do
# send stdout to stdout
# send stderr though pipe
output=$("$@" 2>&1 1>&11 | tee >(cat - >&22)) # return stderr to
# normal stderr as well
# check if error is in stderr
if echo "$output" | grep -q "$error"; then
continue
fi
break
done

View file

@ -1,3 +1,3 @@
#!/bin/sh #!/bin/sh
repo="$HOME/.config/guix" repo="$HOME/.config/guix"
sudo -E guix system -L "$repo/modules" reconfigure "$repo/systems/$(hostname).scm" sudo -E guix-retry guix system -L "$repo/modules" reconfigure "$repo/systems/$(hostname).scm"

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/sh
repo="$HOME/.config/guix" repo="$HOME/.config/guix"
guix home -L "$repo/modules" reconfigure "$repo/home/home.scm" guix-retry guix home -L "$repo/modules" reconfigure "$repo/home/home.scm"
home-manager switch home-manager switch

View file

@ -82,12 +82,24 @@
(invoke "git" "ls-remote" git-url "HEAD") (invoke "git" "ls-remote" git-url "HEAD")
#\tab))) #\tab)))
(define (commit-timestamp git-url commit) (define (git-rev-list git-url local-commit remote-commit)
; get the unix timestamp of a <commit> in git repo <git-url> ;; get how many commits ahead the remote commit is
;; from the current local commit
;; - returns 0 if remote-commit is the same or older
(if (and (string? local-commit)
(string? remote-commit))
(let* ((dir (git-checkout git-url)) (let* ((dir (git-checkout git-url))
(timestamp (timestamp
(invoke "git" "-C" dir "show" "--quiet" "--format=%at" commit))) ;; git rev-list counts #commits
(string->number (string-trim-both timestamp #\newline)))) ;; - returns zero if commits out of order (remote older)
(invoke "git" "-C" dir "rev-list" "--count"
(string-append local-commit
".."
remote-commit))))
(string->number (string-trim-both timestamp #\newline)))
;; return zero of one of the commit
;; hashes provided is invalid
0))
;; ;;
;; core functions ;; core functions
@ -109,23 +121,18 @@
(fold (lambda (local-repo commits) (fold (lambda (local-repo commits)
(let* ((repo-id (car local-repo)) (let* ((repo-id (car local-repo))
(git-url (cadr local-repo)) (git-url (cadr local-repo))
; local
(local-commit (caddr local-repo)) (local-commit (caddr local-repo))
(local-timestamp (commit-timestamp git-url local-commit))
; remote
(remote-commit (assoc-ref remote-commits repo-id)) (remote-commit (assoc-ref remote-commits repo-id))
(remote-timestamp (if (string? remote-commit) (commit-diff (git-rev-list git-url
(commit-timestamp git-url remote-commit))) local-commit
; newest remote-commit)))
(newest-commit (if (and (number? remote-timestamp) ;; dont append these commits to the updated
(> remote-timestamp local-timestamp)) ;; merge list if the remote-commit is not better then
remote-commit)) ;; what we already have locally
; result (if (> commit-diff 0)
(result (if (string? newest-commit) (cons (list repo-id local-commit remote-commit)
(cons (list repo-id local-commit newest-commit)
commits) commits)
commits))) commits)))
result))
'() '()
local-commits)) local-commits))
@ -145,7 +152,8 @@
remote-commit))) remote-commit)))
(read-file path) (read-file path)
commits))) commits)))
(write-file path result))) (write-file path result)
(length commits)))
;; ;;
;; guix functions ;; guix functions
@ -254,15 +262,14 @@
(define %nix-remote-commits (define %nix-remote-commits
(nix-remote-commits %nix-local-commits)) (nix-remote-commits %nix-local-commits))
(update-file (if (> (update-file
%guix-local-commits %guix-local-commits
%guix-remote-commits %guix-remote-commits
%guix-channels-file) %guix-channels-file) 0)
(system* "guix-retry" "guix" "pull" "-C" %guix-channels-file))
(update-file (if (> (update-file
%nix-local-commits %nix-local-commits
%nix-remote-commits %nix-remote-commits
%nix-flake-file) %nix-flake-file) 0)
(system* "nix" "flake" "lock" (dirname %nix-flake-file)))
(system* "guix" "pull" "-C" %guix-channels-file)
(system* "nix" "flake" "lock" (dirname %nix-flake-file))