Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 216 lines 5.7 kB view raw
1{ 2 lib, 3 stdenvNoCC, 4 fetchFromGitHub, 5 nix-update-script, 6 nkf, 7 skktools, 8 useUtf8 ? false, 9}: 10 11let 12 suffix = lib.optionalString useUtf8 ".utf8"; 13 14 mkDictNameValue = 15 { 16 name, 17 description, 18 license, # it's written in the beginning of each file 19 files ? [ "SKK-JISYO.${name}" ], 20 }: 21 { 22 name = lib.toLower (builtins.replaceStrings [ "." ] [ "_" ] name); 23 value = stdenvNoCC.mkDerivation { 24 pname = "skk-jisyo-" + lib.toLower name; 25 version = "0-unstable-2024-08-28"; 26 27 src = fetchFromGitHub { 28 owner = "skk-dev"; 29 repo = "dict"; 30 rev = "4eb91a3bbfef70bde940668ec60f3beae291e971"; 31 sha256 = "sha256-sWz85Q6Bu2WoKsckSp5SlcuPUQN2mcq+BHMqNXQ/aho="; 32 }; 33 34 nativeBuildInputs = lib.optionals useUtf8 [ nkf ]; 35 36 strictDeps = true; 37 38 buildPhase = '' 39 runHook preBuild 40 '' 41 + lib.concatMapStrings (file: '' 42 nkf -w ${file} \ 43 | LC_ALL=C sed 's/coding: [^ ]\{1,\}/coding: utf-8/' \ 44 > ${file + suffix} 45 '') (lib.optionals useUtf8 (map lib.escapeShellArg files)) 46 + '' 47 runHook postBuild 48 ''; 49 50 installPhase = '' 51 runHook preInstall 52 '' 53 + lib.concatMapStrings (file: '' 54 install -Dm644 \ 55 ${lib.escapeShellArg file} \ 56 $out/share/skk/${lib.escapeShellArg (baseNameOf file)} 57 '') (map (file: file + suffix) files) 58 + '' 59 runHook postInstall 60 ''; 61 62 doInstallCheck = true; 63 installCheckPhase = '' 64 emptydict=': 0 candidates$' 65 ${skktools}/bin/skkdic-count /dev/null | grep "$emptydict" 66 ${skktools}/bin/skkdic-count $out/share/skk/* | grep -v "$emptydict" 67 ''; 68 69 passthru.updateScript = nix-update-script { 70 extraArgs = [ 71 "--version" 72 "branch" 73 ]; 74 }; 75 76 meta = with lib; { 77 inherit description license; 78 longDescription = '' 79 This package provides a kana-to-kanji conversion dictionary for the 80 SKK Japanese input method. 81 ''; 82 homepage = "https://github.com/skk-dev/dict"; 83 maintainers = with maintainers; [ 84 yuriaisaka 85 midchildan 86 ]; 87 platforms = platforms.all; 88 }; 89 }; 90 }; 91in 92lib.listToAttrs ( 93 map mkDictNameValue [ 94 { 95 name = "L"; 96 description = "Standard SKK dictionary"; 97 license = lib.licenses.gpl2Plus; 98 } 99 { 100 name = "S"; 101 description = "Small SKK dictionary"; 102 license = lib.licenses.gpl2Plus; 103 } 104 { 105 name = "M"; 106 description = "Medium sized SKK dictionary"; 107 license = lib.licenses.gpl2Plus; 108 } 109 { 110 name = "ML"; 111 description = "Medium to large sized SKK dictionary"; 112 license = lib.licenses.gpl2Plus; 113 } 114 { 115 name = "jinmei"; 116 description = "SKK dictionary for names"; 117 license = lib.licenses.gpl2Plus; 118 } 119 { 120 name = "fullname"; 121 description = "SKK dictionary for celebrities"; 122 license = lib.licenses.gpl2Plus; 123 } 124 { 125 name = "geo"; 126 description = "SKK dictionary for locations"; 127 license = lib.licenses.gpl2Plus; 128 } 129 { 130 name = "propernoun"; 131 description = "SKK dictionary for proper nouns"; 132 license = lib.licenses.gpl2Plus; 133 } 134 { 135 name = "station"; 136 description = "SKK dictionary for stations"; 137 license = lib.licenses.gpl2Plus; 138 } 139 { 140 name = "law"; 141 description = "SKK dictionary for legal terms"; 142 license = lib.licenses.gpl2Plus; 143 } 144 { 145 name = "okinawa"; 146 description = "SKK dictionary for the Okinawan language"; 147 license = lib.licenses.publicDomain; 148 } 149 { 150 name = "china_taiwan"; 151 description = "SKK dictionary for Chinese & Taiwanese locations"; 152 license = lib.licenses.gpl2Plus; 153 } 154 { 155 name = "assoc"; 156 description = "SKK dictionary for abbreviated input"; 157 license = lib.licenses.gpl2Plus; 158 } 159 { 160 name = "edict"; 161 description = "SKK dictionary for English to Japanese translation"; 162 license = lib.licenses.cc-by-sa-30; 163 } 164 { 165 name = "zipcode"; 166 description = "SKK dictionary for Japanese zipcodes"; 167 files = [ 168 "zipcode/SKK-JISYO.zipcode" 169 "zipcode/SKK-JISYO.office.zipcode" 170 ]; 171 license = lib.licenses.publicDomain; 172 } 173 { 174 name = "JIS2"; 175 description = "SKK dictionary for JIS level 2 kanjis"; 176 license = lib.licenses.gpl2Plus; 177 } 178 { 179 name = "JIS3_4"; 180 description = "SKK dictionary for JIS level 3 and 4 kanjis"; 181 license = lib.licenses.gpl2Plus; 182 } 183 { 184 name = "JIS2004"; 185 description = '' 186 A complementary SKK dictionary for JIS3_4 with JIS X 0213:2004 additions" 187 ''; 188 license = lib.licenses.gpl2Plus; 189 } 190 { 191 name = "itaiji"; 192 description = "SKK dictionary for variant kanjis"; 193 license = lib.licenses.publicDomain; 194 } 195 { 196 name = "itaiji.JIS3_4"; 197 description = "SKK dictionary for JIS level 3 and 4 variant kanjis"; 198 license = lib.licenses.gpl2Plus; 199 } 200 { 201 name = "mazegaki"; 202 description = "SKK dictionary for mazegaki"; 203 license = lib.licenses.gpl2Plus; 204 } 205 { 206 name = "emoji"; 207 description = "SKK dictionary for emojis"; 208 license = lib.licenses.unicode-dfs-2016; 209 } 210 { 211 name = "pinyin"; 212 description = "SKK dictionary for pinyin to simplified Chinese input"; 213 license = lib.licenses.gpl1Plus; 214 } 215 ] 216)