1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 7 cfg = config.services.searx; 8 9 configFile = cfg.configFile; 10 11in 12 13{ 14 15 ###### interface 16 17 options = { 18 19 services.searx = { 20 21 enable = mkOption { 22 default = false; 23 description = " 24 Whether to enable the Searx server. See https://github.com/asciimoo/searx 25 "; 26 }; 27 28 configFile = mkOption { 29 default = ""; 30 description = " 31 The path of the Searx server configuration file. If no file 32 is specified, a default file is used (default config file has 33 debug mode enabled). 34 "; 35 }; 36 37 }; 38 39 }; 40 41 42 ###### implementation 43 44 config = mkIf config.services.searx.enable { 45 46 users.extraUsers.searx = 47 { uid = config.ids.uids.searx; 48 description = "Searx user"; 49 createHome = true; 50 home = "/var/lib/searx"; 51 }; 52 53 users.extraGroups.searx = 54 { gid = config.ids.gids.searx; 55 }; 56 57 systemd.services.searx = 58 { 59 description = "Searx server, the meta search engine."; 60 after = [ "network.target" ]; 61 wantedBy = [ "multi-user.target" ]; 62 serviceConfig = { 63 User = "searx"; 64 ExecStart = "${pkgs.pythonPackages.searx}/bin/searx-run"; 65 }; 66 } // (optionalAttrs (configFile != "") { 67 environment.SEARX_SETTINGS_PATH = configFile; 68 }); 69 70 71 environment.systemPackages = [ pkgs.pythonPackages.searx ]; 72 73 }; 74 75}