2016-10-13 00:58:56 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.hound;
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
services.hound = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to enable the hound code search daemon.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
default = "hound";
|
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
User the hound daemon should execute under.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
default = "hound";
|
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
Group the hound daemon should execute under.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraGroups = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ ];
|
|
|
|
example = [ "dialout" ];
|
|
|
|
description = ''
|
|
|
|
List of extra groups that the "hound" user should be a part of.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
home = mkOption {
|
|
|
|
default = "/var/lib/hound";
|
|
|
|
type = types.path;
|
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
default = pkgs.hound;
|
2016-11-21 16:26:03 +01:00
|
|
|
defaultText = "pkgs.hound";
|
|
|
|
type = types.package;
|
2016-10-13 00:58:56 +02:00
|
|
|
description = ''
|
|
|
|
Package for running hound.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkOption {
|
|
|
|
type = types.str;
|
2016-10-16 01:09:05 +02:00
|
|
|
description = ''
|
|
|
|
The full configuration of the Hound daemon. Note the dbpath
|
|
|
|
should be an absolute path to a writable location on disk.
|
|
|
|
'';
|
2016-10-13 00:58:56 +02:00
|
|
|
example = ''
|
|
|
|
{
|
|
|
|
"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 = ''
|
|
|
|
Listen on this IP:port / :port
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2018-06-30 01:58:35 +02:00
|
|
|
users.groups = optional (cfg.group == "hound") {
|
2016-10-13 00:58:56 +02:00
|
|
|
name = "hound";
|
|
|
|
gid = config.ids.gids.hound;
|
|
|
|
};
|
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.users = optional (cfg.user == "hound") {
|
2016-10-13 00:58:56 +02:00
|
|
|
name = "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}";
|
|
|
|
|
|
|
|
};
|
2016-11-08 15:06:51 +01:00
|
|
|
path = [ pkgs.git pkgs.mercurial pkgs.openssh ];
|
2016-10-13 00:58:56 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|