about summary refs log tree commit diff
path: root/corp/russian/data-import/default.nix
blob: cf358874dce626ed8400aa564d8bf5b01f7df61c (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
{ 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
  '';

  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" { } ''
      ${self}/bin/data-import ${openCorpora} $out
    '';
  };
})