hyprland: add update script

Co-authored-by: fufexan <mihai@fufexan.net>
This commit is contained in:
John Titor 2024-06-14 22:12:50 +05:30
parent 2d88a5f17a
commit 7b136032a5
No known key found for this signature in database
GPG Key ID: 29B0514F4E3C1CC0
3 changed files with 55 additions and 3 deletions

View File

@ -0,0 +1,7 @@
{
"branch": "",
"commit_hash": "",
"commit_message": "",
"date": "",
"tag": ""
}

View File

@ -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";

View File

@ -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"