mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-23 15:33:13 +00:00
hyprland: add update script
Co-authored-by: fufexan <mihai@fufexan.net>
This commit is contained in:
parent
2d88a5f17a
commit
7b136032a5
7
pkgs/by-name/hy/hyprland/info.json
Normal file
7
pkgs/by-name/hy/hyprland/info.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"branch": "",
|
||||
"commit_hash": "",
|
||||
"commit_message": "",
|
||||
"date": "",
|
||||
"tag": ""
|
||||
}
|
@ -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";
|
||||
|
35
pkgs/by-name/hy/hyprland/update.sh
Normal file
35
pkgs/by-name/hy/hyprland/update.sh
Normal 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"
|
Loading…
Reference in New Issue
Block a user