diff --git a/flake.nix b/flake.nix index 9ede1c788..3dcfef185 100644 --- a/flake.nix +++ b/flake.nix @@ -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 diff --git a/nix/devShell.nix b/nix/devShell.nix index 0c97ec0da..4aaf4ef5c 100644 --- a/nix/devShell.nix +++ b/nix/devShell.nix @@ -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 diff --git a/nix/pkgs/blessed.nix b/nix/pkgs/blessed.nix new file mode 100644 index 000000000..8b6728f43 --- /dev/null +++ b/nix/pkgs/blessed.nix @@ -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; + }; +} diff --git a/nix/pkgs/ucs-detect.nix b/nix/pkgs/ucs-detect.nix new file mode 100644 index 000000000..07ec6c2fc --- /dev/null +++ b/nix/pkgs/ucs-detect.nix @@ -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 = []; + }; +} diff --git a/nix/wraptest.nix b/nix/pkgs/wraptest.nix similarity index 100% rename from nix/wraptest.nix rename to nix/pkgs/wraptest.nix diff --git a/test/ucs-detect.sh b/test/ucs-detect.sh new file mode 100755 index 000000000..79d5fca0c --- /dev/null +++ b/test/ucs-detect.sh @@ -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