diff options
author | Freya Murphy <freya@freyacat.org> | 2024-12-09 09:13:59 -0500 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2024-12-09 09:13:59 -0500 |
commit | 2a6a04b6ae3e76effb995b167de7e52e85f0392e (patch) | |
tree | 24a9b926d802d839cb1364abac73d3982ba4eb27 /scripts | |
parent | fix element-desktop: firefox segfaults in nonguix electron (diff) | |
download | dotfiles-guix-2a6a04b6ae3e76effb995b167de7e52e85f0392e.tar.gz dotfiles-guix-2a6a04b6ae3e76effb995b167de7e52e85f0392e.tar.bz2 dotfiles-guix-2a6a04b6ae3e76effb995b167de7e52e85f0392e.zip |
update commits, fix hyprland ambiguous, fix `update-commits` script to get timestamps correctly
Diffstat (limited to '')
-rwxr-xr-x | scripts/guix-retry | 21 | ||||
-rwxr-xr-x | scripts/reconfigure-system | 2 | ||||
-rwxr-xr-x | scripts/reconfigure-user | 2 | ||||
-rwxr-xr-x | scripts/update-commits | 73 |
4 files changed, 63 insertions, 35 deletions
diff --git a/scripts/guix-retry b/scripts/guix-retry new file mode 100755 index 0000000..c504048 --- /dev/null +++ b/scripts/guix-retry @@ -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 diff --git a/scripts/reconfigure-system b/scripts/reconfigure-system index 1e38b42..3d378f3 100755 --- a/scripts/reconfigure-system +++ b/scripts/reconfigure-system @@ -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" diff --git a/scripts/reconfigure-user b/scripts/reconfigure-user index 3a0a602..bdc8ca9 100755 --- a/scripts/reconfigure-user +++ b/scripts/reconfigure-user @@ -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 diff --git a/scripts/update-commits b/scripts/update-commits index 9302dcb..15e38b1 100755 --- a/scripts/update-commits +++ b/scripts/update-commits @@ -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))) |