From 65c00a79a99bcd120d53f5e1222dce63f4e89145 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 21 Nov 2026 09:51:04 -0500 Subject: [PATCH] mathesar: work around broken clevercsv (chardet 6) in nixpkgs --- docs/CHANGELOG.md | 9 +++++++++ pkgs/mathesar/package.nix | 18 +++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index bd9cb40c..3c7d80b6 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -367,3 +367,12 @@ `volnoti` service, but this preset still installed the package system-wide, so `gtk2` was still being evaluated (via `man-paths`) and the flake.lock update check kept failing on `nixosConfigurations.staff`. +- Worked around nixpkgs marking `clevercsv` as broken (it requires + `chardet < 6`, unstable ships 6.x), which failed the flake check via + `mathesar` (`pkgs/mathesar/package.nix`). Pinning `clevercsv` itself from + `nixpkgs-stable` does not work (nixpkgs rejects mixing Python derivations + built from different package sets), so `clevercsv` in mathesar's Python set + is now built against a local `chardet` 5.2.0 instead. The override is scoped + to `clevercsv`: replacing `chardet` for the whole set changes `django`'s + inputs and puts two `django`s in the env. Remove once clevercsv supports + chardet 6. diff --git a/pkgs/mathesar/package.nix b/pkgs/mathesar/package.nix index 1dbac2ae..0712bc3e 100644 --- a/pkgs/mathesar/package.nix +++ b/pkgs/mathesar/package.nix @@ -79,6 +79,18 @@ let ]; }; + chardet5 = python313Packages.buildPythonPackage rec { + pname = "chardet"; + version = "5.2.0"; + pyproject = true; + src = fetchPypi { + inherit pname version; + hash = "sha256-Gztv9HmoxBS8P6LAhSmVaVxKAm3NbQYzst0JLKOcHPc="; + }; + build-system = [ python313Packages.setuptools ]; + doCheck = false; + }; + pythonPkg = python313.override { self = python313; packageOverrides = pyfinal: pyprev: { @@ -92,7 +104,11 @@ let # clevercsv's test_encoding_chardet is nondeterministic (chardet # returns None instead of ISO-8859-1/KOI8-R on some platforms), # breaking the build. Skip its test suite. - clevercsv = pyprev.clevercsv.overridePythonAttrs (_old: { + # nixpkgs marks clevercsv as broken with chardet >= 6, so build it + # against chardet 5 (scoped to clevercsv: overriding chardet for the + # whole set changes django's inputs and duplicates it in the env). + # Drop once clevercsv supports chardet 6. + clevercsv = (pyprev.clevercsv.override { chardet = chardet5; }).overridePythonAttrs (_old: { doCheck = false; doInstallCheck = false; });