at 22.05-pre 1.6 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.services.dictd; 7in 8 9{ 10 11 ###### interface 12 13 options = { 14 15 services.dictd = { 16 17 enable = mkOption { 18 type = types.bool; 19 default = false; 20 description = '' 21 Whether to enable the DICT.org dictionary server. 22 ''; 23 }; 24 25 DBs = mkOption { 26 type = types.listOf types.package; 27 default = with pkgs.dictdDBs; [ wiktionary wordnet ]; 28 defaultText = literalExpression "with pkgs.dictdDBs; [ wiktionary wordnet ]"; 29 example = literalExpression "[ pkgs.dictdDBs.nld2eng ]"; 30 description = "List of databases to make available."; 31 }; 32 33 }; 34 35 }; 36 37 38 ###### implementation 39 40 config = let dictdb = pkgs.dictDBCollector { dictlist = map (x: { 41 name = x.name; 42 filename = x; } ) cfg.DBs; }; 43 in mkIf cfg.enable { 44 45 # get the command line client on system path to make some use of the service 46 environment.systemPackages = [ pkgs.dict ]; 47 48 users.users.dictd = 49 { group = "dictd"; 50 description = "DICT.org dictd server"; 51 home = "${dictdb}/share/dictd"; 52 uid = config.ids.uids.dictd; 53 }; 54 55 users.groups.dictd.gid = config.ids.gids.dictd; 56 57 systemd.services.dictd = { 58 description = "DICT.org Dictionary Server"; 59 wantedBy = [ "multi-user.target" ]; 60 environment = { LOCALE_ARCHIVE = "/run/current-system/sw/lib/locale/locale-archive"; }; 61 serviceConfig.Type = "forking"; 62 script = "${pkgs.dict}/sbin/dictd -s -c ${dictdb}/share/dictd/dictd.conf --locale en_US.UTF-8"; 63 }; 64 }; 65}