diff options
author | John Titor <50095635+JohnRTitor@users.noreply.github.com> | 2024-06-14 22:12:50 +0530 |
---|---|---|
committer | John Titor <50095635+JohnRTitor@users.noreply.github.com> | 2024-06-14 22:33:48 +0530 |
commit | 7b136032a56ca0bf1eac8d32bbf298a8dafdf976 (patch) | |
tree | b6e77932a65460fc33eb4d9330a548daf81f54a2 /pkgs/by-name/hy | |
parent | 2d88a5f17a118bbb3e4663196931b98df3321c81 (diff) |
hyprland: add update script
Co-authored-by: fufexan <mihai@fufexan.net>
Diffstat (limited to 'pkgs/by-name/hy')
-rw-r--r-- | pkgs/by-name/hy/hyprland/info.json | 7 | ||||
-rw-r--r-- | pkgs/by-name/hy/hyprland/package.nix | 16 | ||||
-rw-r--r-- | pkgs/by-name/hy/hyprland/update.sh | 35 |
3 files changed, 55 insertions, 3 deletions
diff --git a/pkgs/by-name/hy/hyprland/info.json b/pkgs/by-name/hy/hyprland/info.json new file mode 100644 index 0000000000000..4f9a2cf5b829a --- /dev/null +++ b/pkgs/by-name/hy/hyprland/info.json @@ -0,0 +1,7 @@ +{ + "branch": "", + "commit_hash": "", + "commit_message": "", + "date": "", + "tag": "" +} diff --git a/pkgs/by-name/hy/hyprland/package.nix b/pkgs/by-name/hy/hyprland/package.nix index 958e84ac78f0e..467d12e83a699 100644 --- a/pkgs/by-name/hy/hyprland/package.nix +++ b/pkgs/by-name/hy/hyprland/package.nix @@ -47,6 +47,9 @@ , hidpiXWayland ? false , enableNvidiaPatches ? false }: +let + info = builtins.fromJSON (builtins.readFile ./info.json); +in assert lib.assertMsg (!nvidiaPatches) "The option `nvidiaPatches` has been removed."; assert lib.assertMsg (!enableNvidiaPatches) "The option `enableNvidiaPatches` has been removed."; assert lib.assertMsg (!hidpiXWayland) "The option `hidpiXWayland` has been removed. Please refer https://wiki.hyprland.org/Configuring/XWayland"; @@ -68,9 +71,14 @@ stdenv.mkDerivation (finalAttrs: { sed -i "s#/usr#$out#" src/render/OpenGL.cpp ''; - # used by version.sh - DATE = "2024-05-05"; - HASH = finalAttrs.src.rev; + # variables used by generateVersion.sh script, and shown in `hyprctl version` + BRANCH = info.branch; + COMMITS = info.commit_hash; + DATE = info.date; + DIRTY = ""; + HASH = info.commit_hash; + MESSAGE = info.commit_message; + TAG = info.tag; depsBuildBuild = [ # to find wayland-scanner when cross-compiling @@ -152,6 +160,8 @@ stdenv.mkDerivation (finalAttrs: { passthru.providedSessions = [ "hyprland" ]; + passthru.updateScript = ./update.sh; + meta = with lib; { homepage = "https://github.com/hyprwm/Hyprland"; description = "Dynamic tiling Wayland compositor that doesn't sacrifice on its looks"; diff --git a/pkgs/by-name/hy/hyprland/update.sh b/pkgs/by-name/hy/hyprland/update.sh new file mode 100644 index 0000000000000..c729705f6b1d0 --- /dev/null +++ b/pkgs/by-name/hy/hyprland/update.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env nix-shell +#! nix-shell -i bash -p common-updater-scripts fd jq + +set -eou pipefail + +latest_release="$(curl --silent 'https://api.github.com/repos/hyprwm/Hyprland/releases/latest')" +latest_tag="$(curl --silent 'https://api.github.com/repos/hyprwm/Hyprland/tags?per_page=1')" +commit_hash="$(jq -r '.[0].commit.sha' <<<"$latest_tag")" +latest_commit="$(curl --silent 'https://api.github.com/repos/hyprwm/Hyprland/commits/'"$commit_hash"'')" +commit_message="$(jq -r '.commit.message' <<<"$latest_commit")" + +tag=$(jq -r '.tag_name' <<<"$latest_release") +# drop 'v' prefix +version="${tag#v}" + +branch=$(jq -r '.target_commitish' <<<"$latest_release") + +date=$(jq -r '.created_at' <<<"$latest_release") +# truncate time +date=${date%T*} + +# update version; otherwise fail +update-source-version hyprland "$version" --ignore-same-hash + +# find hyprland dir +files="$(fd --full-path /hyprland/ | head -1)" +dir="${files%/*}" + +echo -e '{ + "branch": "'"$branch"'", + "commit_hash": "'"$commit_hash"'", + "commit_message": "'"$commit_message"'", + "date": "'"$date"'", + "tag": "'"$tag"'" +}' >"$dir/info.json" |