aboutsummaryrefslogtreecommitdiff
path: root/pkgs/stardict/wrapper.nix
blob: 98ee814c178ee294208f3c9fb782b58b107007c1 (plain)
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
{
  stdenv,
  makeBinaryWrapper,
  stardict,
}:
with stardict; let
  drv = stdenv.mkDerivation rec {
    inherit pname;
    inherit version;
    inherit meta;

    nativeBuildInputs = [stardict makeBinaryWrapper];
    dictionaries = [
      /*
      empty and expecting override
      */
    ];

    phases = ["installPhase"];
    installPhase = ''
      mkdir -p $out/bin $out/usr/share/stardict/dic
      for dic in $dictionaries; do
        for path in "$dic"/usr/share/stardict/dic/*; do
          [ -f "$path" ] || continue
          outln="$out/usr/share/stardict/dic/${"$"}{path##*/}"
          [ -e "$outln" ] && continue
          ln -sf "$path" "$outln"
        done
      done

      for bin in ${stardict}/bin/*; do
        makeWrapper "$bin" "$out/bin/${"$"}{bin##*/bin/}" \
          --set STARDICT_DATA_DIR "$out/usr/share/stardict/dic"
      done
    '';

    passthru.withDictionaries = dicts:
      drv.overrideAttrs {
        dictionaries = dicts;
      };
  };
in
  drv