From 1b7cdedcf2ad0979da0d6ec802b18cc4e6742886 Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Fri, 29 Aug 2025 17:38:33 -0400 Subject: [PATCH] nuspell: Add withDict wrapper to bring in line with hunspell --- pkgs/by-name/nu/nuspell/package.nix | 7 +++++ pkgs/by-name/nu/nuspell/wrapper.nix | 47 ++++++++++++++++++++--------- pkgs/top-level/all-packages.nix | 5 ++- 3 files changed, 44 insertions(+), 15 deletions(-) diff --git a/pkgs/by-name/nu/nuspell/package.nix b/pkgs/by-name/nu/nuspell/package.nix index c0caad17608e..bff48444c8b8 100644 --- a/pkgs/by-name/nu/nuspell/package.nix +++ b/pkgs/by-name/nu/nuspell/package.nix @@ -1,6 +1,7 @@ { lib, stdenv, + callPackage, fetchFromGitHub, cmake, ctestCheckHook, @@ -49,7 +50,13 @@ stdenv.mkDerivation (finalAttrs: { ]; passthru = { + withDicts = callPackage ./wrapper.nix { nuspell = finalAttrs.finalPackage; }; + tests = { + wrapper = testers.testVersion { + package = finalAttrs.finalPackage.withDicts (d: [ d.en_US ]); + }; + pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; cmake = testers.hasCmakeConfigModules { diff --git a/pkgs/by-name/nu/nuspell/wrapper.nix b/pkgs/by-name/nu/nuspell/wrapper.nix index 4bb97e623d38..07d0dd104bf1 100644 --- a/pkgs/by-name/nu/nuspell/wrapper.nix +++ b/pkgs/by-name/nu/nuspell/wrapper.nix @@ -1,19 +1,38 @@ { - stdenv, lib, + buildEnv, nuspell, - makeWrapper, - dicts ? [ ], + hunspellDicts, + makeBinaryWrapper, }: -let - searchPath = lib.makeSearchPath "share/hunspell" dicts; -in -stdenv.mkDerivation { - name = (lib.appendToName "with-dicts" nuspell).name; - nativeBuildInputs = [ makeWrapper ]; - buildCommand = '' - makeWrapper ${nuspell}/bin/nuspell $out/bin/nuspell --prefix DICPATH : ${lib.escapeShellArg searchPath} - ''; - meta = removeAttrs nuspell.meta [ "outputsToInstall" ]; -} +lib.makeOverridable ( + dicts: f: + buildEnv { + inherit (lib.appendToName "with-dicts" nuspell) name version; + + paths = f dicts; + + pathsToLink = [ "/share/hunspell" ]; + + nativeBuildInputs = [ makeBinaryWrapper ]; + + postBuild = '' + makeWrapper ${lib.getExe nuspell} $out/bin/nuspell \ + --prefix DICPATH : $out/share/hunspell + ''; + + meta = { + inherit (nuspell.meta) + description + longDescription + homepage + changelog + license + maintainers + mainProgram + platforms + ; + }; + } +) hunspellDicts diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 4a14cf7821d1..1a046033957f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8529,7 +8529,10 @@ with pkgs; nssTools = nss.tools; nuspellWithDicts = - dicts: callPackage ../by-name/nu/nuspell/wrapper.nix { inherit dicts; }; + dicts: + lib.warn "nuspellWithDicts is deprecated, please use nuspell.withDicts instead." nuspell.withDicts ( + _: dicts + ); nv-codec-headers-9 = nv-codec-headers.override { majorVersion = "9"; }; nv-codec-headers-10 = nv-codec-headers.override { majorVersion = "10"; };