at master 1.7 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8let 9 cfg = config.services.whoogle-search; 10in 11{ 12 options = { 13 services.whoogle-search = { 14 enable = lib.mkEnableOption "Whoogle, a metasearch engine"; 15 16 port = lib.mkOption { 17 type = lib.types.port; 18 default = 5000; 19 description = "Port to listen on."; 20 }; 21 22 listenAddress = lib.mkOption { 23 type = lib.types.str; 24 default = "127.0.0.1"; 25 description = "Address to listen on for the web interface."; 26 }; 27 28 extraEnv = lib.mkOption { 29 type = with lib.types; attrsOf str; 30 default = { }; 31 description = '' 32 Extra environment variables to pass to Whoogle, see 33 https://github.com/benbusby/whoogle-search?tab=readme-ov-file#environment-variables 34 ''; 35 }; 36 }; 37 }; 38 39 config = lib.mkIf cfg.enable { 40 41 systemd.services.whoogle-search = { 42 description = "Whoogle Search"; 43 wantedBy = [ "multi-user.target" ]; 44 path = [ pkgs.whoogle-search ]; 45 46 environment = { 47 CONFIG_VOLUME = "/var/lib/whoogle-search"; 48 } 49 // cfg.extraEnv; 50 51 serviceConfig = { 52 Type = "simple"; 53 ExecStart = 54 "${lib.getExe pkgs.whoogle-search}" 55 + " --host '${cfg.listenAddress}'" 56 + " --port '${builtins.toString cfg.port}'"; 57 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; 58 StateDirectory = "whoogle-search"; 59 StateDirectoryMode = "0750"; 60 DynamicUser = true; 61 PrivateTmp = true; 62 ProtectSystem = true; 63 ProtectHome = true; 64 Restart = "on-failure"; 65 RestartSec = "5s"; 66 }; 67 }; 68 }; 69 70 meta.maintainers = with lib.maintainers; [ malte-v ]; 71}