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