about summary refs log tree commit diff
path: root/corp/russian/data-import/default.nix
blob: 6aa8ad6aa3d8877bf1b6a3a65cec7afd17afecec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{ depot, lib, pkgs, ... }:

let
  buildInputs = with pkgs; [
    sqlite
    pkg-config
  ];

  # mirrored input data from OpenCorpora, as of 2023-01-17.
  #
  # This data is licensed under CC-BY-SA.
  openCorporaArchive = pkgs.fetchurl {
    name = "dict.opcorpora.xml.bz";
    url = "https://tazj.in/blobs/opencorpora-20230117.xml.bz2";
    sha256 = "04n5g43fkfc93z6xlwf2qfdrfdfl562pc2ivdb3cbbbsy56gkqg6";
  };

  openCorpora = pkgs.runCommand "dict.opcorpora.xml" { } ''
    ${pkgs.bzip2}/bin/bunzip2 -k -c ${openCorporaArchive} > $out
  '';

  # mirrored input data from OpenRussian, as of 2023-01-17.
  #
  # This data is licensed under CC-BY-SA.
  openRussianArchive = pkgs.fetchzip {
    name = "openrussian-20230117";
    url = "https://tazj.in/blobs/openrussian-20230117.tar.xz";
    sha256 = "06jl7i23cx58a0n2626hb82xlzimixvnxp7lxdw0g664kv9bmw25";
  };

  # development shell with native deps
  shell = pkgs.mkShell {
    inherit buildInputs;

    # make datasets available in the environment
    OPENCORPORA_DATA = openCorpora;
    OPENRUSSIAN_DATA = openRussianArchive;
  };

in
lib.fix (self: depot.third_party.naersk.buildPackage {
  src = depot.third_party.gitignoreSource ./.;
  inherit buildInputs;

  passthru = depot.nix.readTree.drvTargets {
    inherit shell openCorpora;

    # target that actually builds an entire database
    database = pkgs.runCommand "tvl-russian-db.sqlite"
      {
        OPENCORPORA_DATA = openCorpora;
        OPENRUSSIAN_DATA = openRussianArchive;
      } "${self}/bin/data-import --output $out";
  };
})