nur-packages

My NUR packages
git clone git://git.sikmir.ru/nur-packages
Log | Files | Refs | README | LICENSE

default.nix (1865B)


      1 { lib, stdenvNoCC, fetchurl, dict, jq, moreutils, stardict-tools, tatoebatools }:
      2 let
      3   langs = [
      4     "deu eng"
      5     "deu rus"
      6     "eng deu"
      7     "eng epo"
      8     "eng fin"
      9     "eng rus"
     10     "eng swe"
     11     "eng ukr"
     12     "epo eng"
     13     "epo rus"
     14     "fin eng"
     15     "fin rus"
     16     "rus deu"
     17     "rus eng"
     18     "rus epo"
     19     "rus fin"
     20     "rus swe"
     21     "rus ukr"
     22     "swe eng"
     23     "swe rus"
     24     "ukr eng"
     25     "ukr rus"
     26   ];
     27   tatoeba = builtins.fromJSON (builtins.readFile ./tatoeba.json);
     28 in
     29 stdenvNoCC.mkDerivation rec {
     30   pname = "tatoeba";
     31   version = "2022-11-26";
     32 
     33   srcs = lib.mapAttrsToList (name: spec: fetchurl spec) tatoeba;
     34 
     35   unpackPhase = ''
     36     echo "{}" > versions.json
     37   '' + lib.concatMapStringsSep "\n"
     38     (src: ''
     39       bzcat ${src} > ${lib.removeSuffix ".bz2" src.name}
     40       jq '.+{"${lib.removeSuffix ".tsv.bz2" src.name}":"${version} 00:00:00"}' versions.json | \
     41         sponge versions.json
     42     '')
     43     srcs;
     44 
     45   nativeBuildInputs = [ dict jq moreutils stardict-tools tatoebatools ];
     46 
     47   buildPhase =
     48     let
     49       makeDict = lang: with lib; ''
     50         parallel_corpus ${lang} > tatoeba_${replaceStrings [ " " ] [ "_" ] lang}.tab
     51         stardict-tabfile tatoeba_${replaceStrings [ " " ] [ "_" ] lang}.tab
     52       '';
     53     in
     54     ''
     55       export XDG_DATA_HOME=$PWD
     56       mkdir -p tatoebatools/{links,sentences_detailed}
     57       mv *_links.tsv tatoebatools/links
     58       mv *_sentences_detailed.tsv tatoebatools/sentences_detailed
     59       mv versions.json tatoebatools
     60       ${lib.concatMapStringsSep "\n" makeDict langs}
     61     '';
     62 
     63   installPhase = "install -Dm644 *.{dict*,idx,ifo} -t $out";
     64 
     65   meta = with lib; {
     66     description = "Tatoeba is a collection of sentences and translations";
     67     homepage = "https://tatoeba.org/";
     68     license = licenses.free;
     69     maintainers = with maintainers; [ sikmir ];
     70     platforms = platforms.all;
     71     skip.ci = true;
     72   };
     73 }