From aa86ee72121ae133bd0f7b84c070c73bc5a9685f Mon Sep 17 00:00:00 2001 From: Sapphire Date: Wed, 21 May 2025 05:41:49 -0500 Subject: [PATCH] Read monado rev from file --- .github/workflows/Build.yml | 2 +- CMakeLists.txt | 3 ++- flake.nix | 14 +++----------- monado-rev | 1 + tools/gen_flatpak_manifest.py | 2 +- 5 files changed, 8 insertions(+), 14 deletions(-) create mode 100644 monado-rev diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index 1537c5b3..e61a4874 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -474,7 +474,7 @@ jobs: - name: Download monado run: | - MONADO_COMMIT=$(grep -zo "FetchContent_Declare(monado[^)]*)" wivrn/CMakeLists.txt | sed -ze "s/^.*GIT_TAG *\([^ )]*\).*$/\1/" | tr -d '\0') + MONADO_COMMIT=$(cat wivrn/monado-rev) wget https://gitlab.freedesktop.org/monado/monado/-/archive/$MONADO_COMMIT/monado-$MONADO_COMMIT.tar.gz mkdir wivrn/monado-src diff --git a/CMakeLists.txt b/CMakeLists.txt index 98678d01..3e213697 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -284,11 +284,12 @@ FetchContent_Declare(uni-algo EXCLUDE_FROM_ALL SYSTEM URL https://github.co URL_HASH SHA256=f2a1539cd8635bc6088d05144a73ecfe7b4d74ee0361fabed6f87f9f19e74ca9) file(GLOB MONADO_PATCHES CONFIGURE_DEPENDS patches/monado/*) +file(READ monado-rev MONADO_REV) # Server dependencies FetchContent_Declare(monado GIT_REPOSITORY https://gitlab.freedesktop.org/monado/monado # The flatpak manifest is updated automatically - GIT_TAG 2a6932d46dad9aa957205e8a47ec2baa33041076 + GIT_TAG ${MONADO_REV} PATCH_COMMAND ${CMAKE_CURRENT_LIST_DIR}/patches/apply.sh ${MONADO_PATCHES} EXCLUDE_FROM_ALL ) diff --git a/flake.nix b/flake.nix index 5c33ce92..df94fe73 100644 --- a/flake.nix +++ b/flake.nix @@ -22,17 +22,8 @@ version = "next"; # Because src is just a folder path and not a set from a fetcher, it doesn't need to be unpacked, so having a postUnpack throws an error. + # We also don't need the check since we read the revision from the monado-rev file. postUnpack = null; - prePatch = '' - ourMonadoRev="${finalAttrs.monado.src.rev}" - theirMonadoRev=$(sed -n '/FetchContent_Declare(monado/,/)/p' CMakeLists.txt | grep "GIT_TAG" | awk '{print $2}') - if [ ! "$theirMonadoRev" == "$ourMonadoRev" ]; then - echo "Our Monado source revision doesn't match CMakeLists.txt." >&2 - echo " theirs: $theirMonadoRev" >&2 - echo " ours: $ourMonadoRev" >&2 - return 1 - fi - ''; monado = pkgs.applyPatches { inherit (oldAttrs.monado) patches postPatch; @@ -40,7 +31,8 @@ inherit (oldAttrs.monado.src) owner repo; domain = "gitlab.freedesktop.org"; # Keep in sync with CMakeLists.txt monado rev - rev = "2a6932d46dad9aa957205e8a47ec2baa33041076"; + rev = builtins.readFile ./monado-rev; + # Nix will output the correct hash when it doesn't match hash = "sha256-Bus9GTNC4+nOSwN8pUsMaFsiXjlpHYioQfBLxbQEF+0="; }; }; diff --git a/monado-rev b/monado-rev new file mode 100644 index 00000000..f4e7a1ab --- /dev/null +++ b/monado-rev @@ -0,0 +1 @@ +2a6932d46dad9aa957205e8a47ec2baa33041076 \ No newline at end of file diff --git a/tools/gen_flatpak_manifest.py b/tools/gen_flatpak_manifest.py index 5c82d1c5..7715416b 100755 --- a/tools/gen_flatpak_manifest.py +++ b/tools/gen_flatpak_manifest.py @@ -58,7 +58,7 @@ if __name__ == "__main__": json.dump(gen_src, f, indent=4, sort_keys=False) - monado_commit = cmake.get("monado", "GIT_TAG") + monado_commit = open(os.path.join(root, "monado-rev")).read() boostpfr_url = cmake.get("boostpfr", "URL") boostpfr_sha256 = cmake.get("boostpfr", "URL_HASH").split("=")[-1]