3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/nixos/modules/services/search/hound.nix
pennae 2e751c0772 treewide: automatically md-convert option descriptions
the conversion procedure is simple:

 - find all things that look like options, ie calls to either `mkOption`
   or `lib.mkOption` that take an attrset. remember the attrset as the
   option
 - for all options, find a `description` attribute who's value is not a
   call to `mdDoc` or `lib.mdDoc`
 - textually convert the entire value of the attribute to MD with a few
   simple regexes (the set from mdize-module.sh)
 - if the change produced a change in the manual output, discard
 - if the change kept the manual unchanged, add some text to the
   description to make sure we've actually found an option. if the
   manual changes this time, keep the converted description

this procedure converts 80% of nixos options to markdown. around 2000
options remain to be inspected, but most of those fail the "does not
change the manual output check": currently the MD conversion process
does not faithfully convert docbook tags like <code> and <package>, so
any option using such tags will not be converted at all.
2022-07-30 15:16:34 +02:00

128 lines
3.3 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.hound;
in {
options = {
services.hound = {
enable = mkOption {
type = types.bool;
default = false;
description = lib.mdDoc ''
Whether to enable the hound code search daemon.
'';
};
user = mkOption {
default = "hound";
type = types.str;
description = lib.mdDoc ''
User the hound daemon should execute under.
'';
};
group = mkOption {
default = "hound";
type = types.str;
description = lib.mdDoc ''
Group the hound daemon should execute under.
'';
};
extraGroups = mkOption {
type = types.listOf types.str;
default = [ ];
example = [ "dialout" ];
description = lib.mdDoc ''
List of extra groups that the "hound" user should be a part of.
'';
};
home = mkOption {
default = "/var/lib/hound";
type = types.path;
description = lib.mdDoc ''
The path to use as hound's $HOME. If the default user
"hound" is configured then this is the home of the "hound"
user.
'';
};
package = mkOption {
default = pkgs.hound;
defaultText = literalExpression "pkgs.hound";
type = types.package;
description = lib.mdDoc ''
Package for running hound.
'';
};
config = mkOption {
type = types.str;
description = lib.mdDoc ''
The full configuration of the Hound daemon. Note the dbpath
should be an absolute path to a writable location on disk.
'';
example = literalExpression ''
'''
{
"max-concurrent-indexers" : 2,
"dbpath" : "''${services.hound.home}/data",
"repos" : {
"nixpkgs": {
"url" : "https://www.github.com/NixOS/nixpkgs.git"
}
}
}
'''
'';
};
listen = mkOption {
type = types.str;
default = "0.0.0.0:6080";
example = "127.0.0.1:6080 or just :6080";
description = lib.mdDoc ''
Listen on this IP:port / :port
'';
};
};
};
config = mkIf cfg.enable {
users.groups = optionalAttrs (cfg.group == "hound") {
hound.gid = config.ids.gids.hound;
};
users.users = optionalAttrs (cfg.user == "hound") {
hound = {
description = "hound code search";
createHome = true;
home = cfg.home;
group = cfg.group;
extraGroups = cfg.extraGroups;
uid = config.ids.uids.hound;
};
};
systemd.services.hound = {
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 ${pkgs.writeText "hound.json" cfg.config}";
};
path = [ pkgs.git pkgs.mercurial pkgs.openssh ];
};
};
}