aboutsummaryrefslogtreecommitdiff
path: root/pkgs/sdcv
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2022-06-22 15:54:04 +0200
committerKarel Kočí <cynerd@email.cz>2022-06-22 15:55:14 +0200
commit5ec374830995b705cae116ea14e6190f8c4d3a29 (patch)
treea59c40d6b8bd95e86df6a0857ff10cbca506aabe /pkgs/sdcv
parent5679c4ad2745fbd62a40be8beaa5c68b20c0a6bf (diff)
downloadnixos-personal-5ec374830995b705cae116ea14e6190f8c4d3a29.tar.gz
nixos-personal-5ec374830995b705cae116ea14e6190f8c4d3a29.tar.bz2
nixos-personal-5ec374830995b705cae116ea14e6190f8c4d3a29.zip
Add sdcv and stardict dictionaries
Diffstat (limited to 'pkgs/sdcv')
-rw-r--r--pkgs/sdcv/default.nix26
-rw-r--r--pkgs/sdcv/wrapper.nix37
2 files changed, 63 insertions, 0 deletions
diff --git a/pkgs/sdcv/default.nix b/pkgs/sdcv/default.nix
new file mode 100644
index 0000000..7e9527f
--- /dev/null
+++ b/pkgs/sdcv/default.nix
@@ -0,0 +1,26 @@
+{ lib, stdenv, fetchFromGitHub
+, cmake, pkg-config, gettext
+, zlib, glib, pcre, readline
+}:
+
+stdenv.mkDerivation rec {
+ pname = "sdcv";
+ version = "0.5.3";
+
+ src = fetchFromGitHub {
+ owner = "Dushistov";
+ repo = pname;
+ rev = "d054adb37c635ececabc31b147c968a480d1891a";
+ hash = "sha256-mJ9LrQ/l0SRmueg+IfGnS0NcNheGdOZ2Gl7KMFiK6is=";
+ };
+
+ nativeBuildInputs = [ cmake pkg-config gettext ];
+ buildInputs = [ zlib glib pcre readline ];
+ makeFlags = "sdcv lang";
+
+ meta = with lib; {
+ description = "Console version of Stardict program";
+ homepage = "https://dushistov.github.io/sdcv/";
+ license = licenses.gpl2;
+ };
+}
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