nix: add ucs-detect

This makes `ucs-detect` available in our Nix environment so that we can
run tests on our Unicode support. In the future, I'd like to modify our
CI to run this too.

This also adds a `./test/ucs-detect.sh` script that runs `ucs-detect`
with consistent options that match the upstream test styles.
pull/9506/head
Mitchell Hashimoto 2025-11-06 08:14:13 -08:00
parent 9786d0ea73
commit a315f8f32e
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
6 changed files with 103 additions and 1 deletions

View File

@ -50,8 +50,16 @@
in {
devShell.${system} = pkgs.callPackage ./nix/devShell.nix {
zig = zig.packages.${system}."0.15.2";
wraptest = pkgs.callPackage ./nix/wraptest.nix {};
wraptest = pkgs.callPackage ./nix/pkgs/wraptest.nix {};
zon2nix = zon2nix;
python3 = pkgs.python3.override {
self = pkgs.python3;
packageOverrides = pyfinal: pyprev: {
blessed = pyfinal.callPackage ./nix/pkgs/blessed.nix {};
ucs-detect = pyfinal.callPackage ./nix/pkgs/ucs-detect.nix {};
};
};
};
packages.${system} = let

View File

@ -136,6 +136,11 @@ in
blueprint-compiler
libadwaita
gtk4
# Python packages
(python3.withPackages (python-pkgs: [
python-pkgs.ucs-detect
]))
]
++ lib.optionals stdenv.hostPlatform.isLinux [
# My nix shell environment installs the non-interactive version

37
nix/pkgs/blessed.nix Normal file
View File

@ -0,0 +1,37 @@
{
lib,
buildPythonPackage,
fetchPypi,
pythonOlder,
flit-core,
six,
wcwidth,
}:
buildPythonPackage rec {
pname = "blessed";
version = "1.23.0";
pyproject = true;
disabled = pythonOlder "3.7";
src = fetchPypi {
inherit pname version;
hash = "sha256-VlkaMpZvcE9hMfFACvQVHZ6PX0FEEzpcoDQBl2Pe53s=";
};
build-system = [flit-core];
propagatedBuildInputs = [
wcwidth
six
];
doCheck = false;
meta = with lib; {
homepage = "https://github.com/jquast/blessed";
description = "Thin, practical wrapper around terminal capabilities in Python";
maintainers = [];
license = licenses.mit;
};
}

41
nix/pkgs/ucs-detect.nix Normal file
View File

@ -0,0 +1,41 @@
{
lib,
buildPythonPackage,
fetchPypi,
pythonOlder,
setuptools,
# Dependencies
blessed,
wcwidth,
pyyaml,
}:
buildPythonPackage rec {
pname = "ucs-detect";
version = "1.0.8";
pyproject = true;
disabled = pythonOlder "3.8";
src = fetchPypi {
inherit version;
pname = "ucs_detect";
hash = "sha256-ihB+tZCd6ykdeXYxc6V1Q6xALQ+xdCW5yqSL7oppqJc=";
};
dependencies = [
blessed
wcwidth
pyyaml
];
nativeBuildInputs = [setuptools];
doCheck = false;
meta = with lib; {
description = "Measures number of Terminal column cells of wide-character codes";
homepage = "https://github.com/jquast/ucs-detect";
license = licenses.mit;
maintainers = [];
};
}

11
test/ucs-detect.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
# This runs ucs-detect with the same settings consistently so we can
# compare our results over time. This is based on:
# https://github.com/jquast/ucs-detect/blob/2958b7766783c92b3aad6a55e1e752cbe07ccaf3/data/ghostty.yaml
ucs-detect \
--limit-codepoints=5000 \
--limit-words=5000 \
--limit-errors=1000 \
--quick=false \
--stream=stderr