From ea86aa9af0754ed3cef9cc202ae2e885b91aafdd Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Mon, 28 Jul 2025 09:31:53 +0200 Subject: [PATCH] glasgow: 0-unstable-2025-01-26 -> 0-unstable-2025-07-28 In addition to bringing all the new features since then, upstream now uses the same sdcc version, and with an additional normalization phase, we come up with exactly the same firmware as them (and validate this). We previously had both the committed firmware blob from upstream, as well as our built firmware in our output, and only used the upstream one due to a packaging bug (changed path). Dependencies were slightly reordered, instead of propagatedBuildInputs we now use dependencies, and build-system is used instead of nativeBuildInputs to more align with python package style. I also documented why pytestCheckHook cannot be used. --- pkgs/by-name/gl/glasgow/package.nix | 43 ++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/pkgs/by-name/gl/glasgow/package.nix b/pkgs/by-name/gl/glasgow/package.nix index 53567312e05d..ed41e2e22f30 100644 --- a/pkgs/by-name/gl/glasgow/package.nix +++ b/pkgs/by-name/gl/glasgow/package.nix @@ -11,54 +11,71 @@ python3.pkgs.buildPythonApplication rec { pname = "glasgow"; - version = "0-unstable-2025-01-26"; + version = "0-unstable-2025-07-28"; # from `pdm show` realVersion = let tag = builtins.elemAt (lib.splitString "-" version) 0; rev = lib.substring 0 7 src.rev; in - "${tag}.1.dev2085+g${rev}"; + "${tag}.1.dev2611+g${rev}"; + # the latest commit ID touching the `firmware` directory, can differ from rev! + firmwareGitRev = "4fe35360"; pyproject = true; src = fetchFromGitHub { owner = "GlasgowEmbedded"; repo = "glasgow"; - rev = "2a67f79d6025a06e98277956cbb036c4237960f1"; - sha256 = "sha256-THunn3Oz+eldjQ72TGuq4Egnn6fiMiGG/UtYVRc/tfU="; + rev = "18442e9684cdda4bb2cbd2be9c31b3c6dffc625a"; + hash = "sha256-b0kpgCHMk5Ylj4hY29sHRzY/zI1JXReHioHxHSO4h5E="; }; nativeBuildInputs = [ - python3.pkgs.pdm-backend sdcc ]; - propagatedBuildInputs = with python3.pkgs; [ - typing-extensions + build-system = [ + python3.pkgs.pdm-backend + ]; + + dependencies = with python3.pkgs; [ + aiohttp amaranth + cobs + fx2 + importlib-resources + libusb1 packaging platformdirs - fx2 - libusb1 pyvcd - aiohttp + typing-extensions ]; nativeCheckInputs = [ + # pytestCheckHook discovers way less tests python3.pkgs.unittestCheckHook - yosys icestorm nextpnr + yosys ]; + unittestFlags = [ "-v" ]; + enableParallelBuilding = true; __darwinAllowLocalNetworking = true; preBuild = '' - make -C firmware LIBFX2=${python3.pkgs.fx2}/share/libfx2 - cp firmware/glasgow.ihex software/glasgow + make -C firmware GIT_REV_SHORT=${firmwareGitRev} LIBFX2=${python3.pkgs.fx2}/share/libfx2 + + # Normalize the .ihex file, see ./software/deploy-firmware.sh. + ${python3.withPackages (p: [ p.fx2 ])}/bin/python firmware/normalize.py \ + firmware/glasgow.ihex firmware/glasgow.ihex + + # Ensure the compiled firmware is exactly the same as the one shipped in the repo. + cmp -s firmware/glasgow.ihex software/glasgow/hardware/firmware.ihex + cd software export PDM_BUILD_SCM_VERSION="${realVersion}" '';