nixpkgs/nixos/modules/services/search/hound.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

113 lines
3.2 KiB
Nix
Raw Normal View History

2016-10-12 22:58:56 +00:00
{ config, lib, pkgs, ... }:
let
cfg = config.services.hound;
settingsFormat = pkgs.formats.json { };
2016-10-12 22:58:56 +00:00
in {
imports = [
(lib.mkRemovedOptionModule [ "services" "hound" "extraGroups" ] "Use users.users.hound.extraGroups instead")
(lib.mkChangedOptionModule [ "services" "hound" "config" ] [ "services" "hound" "settings" ] (config: builtins.fromJSON config.services.hound.config))
];
2024-06-26 16:57:42 +00:00
meta.maintainers = with lib.maintainers; [ SuperSandro2000 ];
2016-10-12 22:58:56 +00:00
options = {
services.hound = {
2024-06-26 16:57:42 +00:00
enable = lib.mkEnableOption "hound";
2016-10-12 22:58:56 +00:00
2024-06-26 16:57:42 +00:00
package = lib.mkPackageOption pkgs "hound" { };
2024-06-26 16:57:42 +00:00
user = lib.mkOption {
2016-10-12 22:58:56 +00:00
default = "hound";
2024-06-26 16:57:42 +00:00
type = lib.types.str;
2016-10-12 22:58:56 +00:00
description = ''
User the hound daemon should execute under.
'';
};
2024-06-26 16:57:42 +00:00
group = lib.mkOption {
2016-10-12 22:58:56 +00:00
default = "hound";
2024-06-26 16:57:42 +00:00
type = lib.types.str;
2016-10-12 22:58:56 +00:00
description = ''
Group the hound daemon should execute under.
'';
};
2024-06-26 16:57:42 +00:00
home = lib.mkOption {
2016-10-12 22:58:56 +00:00
default = "/var/lib/hound";
2024-06-26 16:57:42 +00:00
type = lib.types.path;
2016-10-12 22:58:56 +00:00
description = ''
The path to use as hound's $HOME.
If the default user "hound" is configured then this is the home of the "hound" user.
2016-10-12 22:58:56 +00:00
'';
};
2024-06-26 16:57:42 +00:00
settings = lib.mkOption {
type = settingsFormat.type;
2024-06-26 16:57:42 +00:00
example = lib.literalExpression ''
{
max-concurrent-indexers = 2;
repos.nixpkgs.url = "https://www.github.com/NixOS/nixpkgs.git";
}
2016-10-12 22:58:56 +00:00
'';
description = ''
The full configuration of the Hound daemon.
See the upstream documentation <https://github.com/hound-search/hound/blob/main/docs/config-options.md> for details.
:::{.note}
The `dbpath` should be an absolute path to a writable directory.
:::.com/hound-search/hound/blob/main/docs/config-options.md>.
'';
2016-10-12 22:58:56 +00:00
};
2024-06-26 16:57:42 +00:00
listen = lib.mkOption {
type = lib.types.str;
2016-10-12 22:58:56 +00:00
default = "0.0.0.0:6080";
example = ":6080";
2016-10-12 22:58:56 +00:00
description = ''
Listen on this [IP]:port
2016-10-12 22:58:56 +00:00
'';
};
};
};
2024-06-26 16:57:42 +00:00
config = lib.mkIf cfg.enable {
users.groups = lib.mkIf (cfg.group == "hound") {
hound = { };
2016-10-12 22:58:56 +00:00
};
users.users = lib.mkIf (cfg.user == "hound") {
hound = {
description = "Hound code search";
createHome = true;
isSystemUser = true;
inherit (cfg) home group;
};
2016-10-12 22:58:56 +00:00
};
environment.etc."hound/config.json".source = pkgs.writeTextFile {
name = "hound-config";
text = builtins.toJSON cfg.settings;
checkPhase = ''
${cfg.package}/bin/houndd -check-conf -conf $out
'';
};
services.hound.settings = {
dbpath = "${config.services.hound.home}/data";
};
systemd.services.hound = {
2016-10-12 22:58:56 +00:00
description = "Hound Code Search";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
User = cfg.user;
Group = cfg.group;
WorkingDirectory = cfg.home;
ExecStartPre = "${pkgs.git}/bin/git config --global --replace-all http.sslCAinfo /etc/ssl/certs/ca-certificates.crt";
ExecStart = "${cfg.package}/bin/houndd -addr ${cfg.listen} -conf /etc/hound/config.json";
2016-10-12 22:58:56 +00:00
};
};
};
}