update commits, fix hyprland ambiguous, fix update-commits
script to get timestamps correctly
This commit is contained in:
parent
7ab26f7212
commit
2a6a04b6ae
6 changed files with 67 additions and 38 deletions
|
@ -3,7 +3,7 @@
|
|||
(url "https://git.savannah.gnu.org/git/guix.git")
|
||||
(branch "master")
|
||||
(commit
|
||||
"c56505e399834a3f68cf2b6715b42f12ceea217a")
|
||||
"9d09b0cf841fb657a1aec12e9bab68e00c2b493c")
|
||||
(introduction
|
||||
(make-channel-introduction
|
||||
"9edb3f66fd807b096b48283debdcddccfea34bad"
|
||||
|
@ -14,7 +14,7 @@
|
|||
(url "https://gitlab.com/nonguix/nonguix.git")
|
||||
(branch "master")
|
||||
(commit
|
||||
"720df79727769e4230706e891841ec6f0b8b3890")
|
||||
"4aa03a3ccf6bb693bd4c99900bcd81845c249bbe")
|
||||
(introduction
|
||||
(make-channel-introduction
|
||||
"897c1a470da759236cc11798f4e0a5f7d4d59fbc"
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
(sakura home services pipewire)
|
||||
(sakura packages gnome-xyz)
|
||||
(sakura packages sound)
|
||||
(sakura packages hypr)
|
||||
(sakura packages vim))
|
||||
|
||||
|
||||
|
@ -34,7 +35,6 @@
|
|||
"swaylock-effects"
|
||||
|
||||
; hyprland
|
||||
"hyprland"
|
||||
"hyprlock"
|
||||
"hyprpaper"
|
||||
"hypridle"
|
||||
|
@ -141,6 +141,7 @@
|
|||
|
||||
; add ca certs and ambiguous packages
|
||||
(list freya-ca-certs
|
||||
hyprland
|
||||
orchis-theme-2024
|
||||
blueman-sakura)))
|
||||
|
||||
|
|
21
scripts/guix-retry
Executable file
21
scripts/guix-retry
Executable 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
|
|
@ -1,3 +1,3 @@
|
|||
#!/bin/sh
|
||||
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"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/sh
|
||||
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
|
||||
|
|
|
@ -82,12 +82,24 @@
|
|||
(invoke "git" "ls-remote" git-url "HEAD")
|
||||
#\tab)))
|
||||
|
||||
(define (commit-timestamp git-url commit)
|
||||
; get the unix timestamp of a <commit> in git repo <git-url>
|
||||
(let* ((dir (git-checkout git-url))
|
||||
(timestamp
|
||||
(invoke "git" "-C" dir "show" "--quiet" "--format=%at" commit)))
|
||||
(string->number (string-trim-both timestamp #\newline))))
|
||||
(define (git-rev-list git-url local-commit remote-commit)
|
||||
;; 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))
|
||||
(timestamp
|
||||
;; git rev-list counts #commits
|
||||
;; - 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
|
||||
|
@ -109,23 +121,18 @@
|
|||
(fold (lambda (local-repo commits)
|
||||
(let* ((repo-id (car local-repo))
|
||||
(git-url (cadr local-repo))
|
||||
; local
|
||||
(local-commit (caddr local-repo))
|
||||
(local-timestamp (commit-timestamp git-url local-commit))
|
||||
; remote
|
||||
(remote-commit (assoc-ref remote-commits repo-id))
|
||||
(remote-timestamp (if (string? remote-commit)
|
||||
(commit-timestamp git-url remote-commit)))
|
||||
; newest
|
||||
(newest-commit (if (and (number? remote-timestamp)
|
||||
(> remote-timestamp local-timestamp))
|
||||
remote-commit))
|
||||
; result
|
||||
(result (if (string? newest-commit)
|
||||
(cons (list repo-id local-commit newest-commit)
|
||||
commits)
|
||||
commits)))
|
||||
result))
|
||||
(commit-diff (git-rev-list git-url
|
||||
local-commit
|
||||
remote-commit)))
|
||||
;; dont append these commits to the updated
|
||||
;; merge list if the remote-commit is not better then
|
||||
;; what we already have locally
|
||||
(if (> commit-diff 0)
|
||||
(cons (list repo-id local-commit remote-commit)
|
||||
commits)
|
||||
commits)))
|
||||
'()
|
||||
local-commits))
|
||||
|
||||
|
@ -145,7 +152,8 @@
|
|||
remote-commit)))
|
||||
(read-file path)
|
||||
commits)))
|
||||
(write-file path result)))
|
||||
(write-file path result)
|
||||
(length commits)))
|
||||
|
||||
;;
|
||||
;; guix functions
|
||||
|
@ -254,15 +262,14 @@
|
|||
(define %nix-remote-commits
|
||||
(nix-remote-commits %nix-local-commits))
|
||||
|
||||
(update-file
|
||||
%guix-local-commits
|
||||
%guix-remote-commits
|
||||
%guix-channels-file)
|
||||
(if (> (update-file
|
||||
%guix-local-commits
|
||||
%guix-remote-commits
|
||||
%guix-channels-file) 0)
|
||||
(system* "guix-retry" "guix" "pull" "-C" %guix-channels-file))
|
||||
|
||||
(update-file
|
||||
%nix-local-commits
|
||||
%nix-remote-commits
|
||||
%nix-flake-file)
|
||||
|
||||
(system* "guix" "pull" "-C" %guix-channels-file)
|
||||
(system* "nix" "flake" "lock" (dirname %nix-flake-file))
|
||||
(if (> (update-file
|
||||
%nix-local-commits
|
||||
%nix-remote-commits
|
||||
%nix-flake-file) 0)
|
||||
(system* "nix" "flake" "lock" (dirname %nix-flake-file)))
|
||||
|
|
Loading…
Reference in a new issue