aboutsummaryrefslogtreecommitdiff
path: root/pkgs/sdcv/wrapper.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/sdcv/wrapper.nix')
-rw-r--r--pkgs/sdcv/wrapper.nix37
1 files changed, 37 insertions, 0 deletions
diff --git a/pkgs/sdcv/wrapper.nix b/pkgs/sdcv/wrapper.nix
new file mode 100644
index 0000000..e26c58c
--- /dev/null
+++ b/pkgs/sdcv/wrapper.nix
@@ -0,0 +1,37 @@
+{ lib, stdenv, makeBinaryWrapper
+, sdcv-unwrapped
+}:
+
+with sdcv-unwrapped;
+
+let
+
+ drv = stdenv.mkDerivation rec {
+ inherit pname;
+ inherit version;
+ inherit meta;
+
+ nativeBuildInputs = [ sdcv-unwrapped 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
+ makeWrapper ${sdcv-unwrapped}/bin/sdcv $out/bin/sdcv \
+ --set STARDICT_DATA_DIR $out/usr/share/stardict/dic
+ '';
+
+ passthru.withDictionaries = dicts: drv.overrideAttrs (oldAttrs: {
+ dictionaries = dicts;
+ });
+ };
+
+in drv