Packaged a Korean spellcheck dictionary. Where / how to upstream?

I don’t have any packages in nixkpgs but found something that would be useful to add. There’s a Korean hunspell dictionary that was pretty easy to build.

The following hunks were used to construct a flake:

    korean-hunspell-src = {
      url = "github:spellcheck-ko/hunspell-dict-ko";
      flake = false;
    };

        korean-hunspell = pkgs.stdenv.mkDerivation {
          name = "ko";
          src = korean-hunspell-src;
          pname = "hunspell-dict-ko";
          buildInputs = [
            pkgs.python3
            pkgs.python3.pkgs.pyaml
          ];
          installPhase = ''
            mkdir -p $out/share/hunspell
            cp ko.aff $out/share/hunspell/ko.aff
            cp ko.dic $out/share/hunspell/ko.dic
          '';
        };

I looked at the source for some spellcheck packages and realized most of them come from a fairly regular scheme that won’t be appropriate for the source I found. Presuming I was going to go from no experience to a first PR, what do I want to know?

Alternatively, these hunks are working, and I would appreciate someone picking up from here.

The dictionary would be added to the /pkgs/development/libraries/hunspell/dictionaries.nix file.

pkgs.stdenv.mkDerivation should be converted to the mkDict function.

The value of src should be converted to a fetchFromGitHub something like this:

src = fetchFromGitHub {
  owner = "spellcheck-ko";
  repo = "hunspell-dict-ko";
  rev = version;
  hash = "";
};

name should be removed and version should be added, name will be generated from pname and version.

installPhase can also be removed, as an improved version of it is already included with the mkDict function.

In buildInputs the pkgs can be removed from the packages as we directly import the packages and don’t want the whole package set.

We also require a meta attribute which includes metadata information about the package, something like this:

meta = with lib; {
  description = "Hunspell dictionary for Korean";
  homepage = "https://github.com/spellcheck-ko/hunspell-dict-ko";
  license = with licenses; [ mpl11 gpl2Plus lgpl21Plus cc-by-sa-40 cc-by-40 gpl3Plus ];
  maintainers = with maintainers; [ yourname ];
  platforms = platforms.all;
};

the maintainers part requires that you add your self to the maintainers list at /maintainers/maintainer-list.nix

You would also need to add the mkDict specific dictFileName and readmeFile.

The final result would look something like this:

ko = mkDict rec {
  pname = "hunspell-dict-ko";
  version = "0.7.94";

  src = fetchFromGitHub {
    owner = "spellcheck-ko";
    repo = "hunspell-dict-ko";
    rev = version;
    hash = "";
  };

  dictFileName = "ko";
  readmeFile = "README.md";
          
  buildInputs = [
    python3
    python3.pkgs.pyaml
  ];

  meta = with lib; {
    description = "Hunspell dictionary for Korean";
    homepage = "https://github.com/spellcheck-ko/hunspell-dict-ko";
    license = with licenses; [ mpl11 gpl2Plus lgpl21Plus cc-by-sa-40 cc-by-40 gpl3Plus ];
    maintainers = with maintainers; [ yourname ];
    platforms = platforms.all;
  };
};

Some more information can be found at https://github.com/NixOS/nixpkgs/blob/82f422c567168dcfab1f86d842fa678df393ec16/pkgs/README.md and https://github.com/NixOS/nixpkgs/blob/82f422c567168dcfab1f86d842fa678df393ec16/CONTRIBUTING.md

If you have any more questions, just ask :smile: