2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.hound;
|
|
|
|
in {
|
2024-01-02 11:29:13 +00:00
|
|
|
imports = [
|
|
|
|
(lib.mkRemovedOptionModule [ "services" "hound" "extraGroups" ] "Use users.users.hound.extraGroups instead")
|
|
|
|
];
|
|
|
|
|
|
|
|
meta.maintainers = with maintainers; [ SuperSandro2000 ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
options = {
|
|
|
|
services.hound = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Whether to enable the hound code search daemon.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
package = mkPackageOptionMD pkgs "hound" { };
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
user = mkOption {
|
|
|
|
default = "hound";
|
|
|
|
type = types.str;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
User the hound daemon should execute under.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
default = "hound";
|
|
|
|
type = types.str;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Group the hound daemon should execute under.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
home = mkOption {
|
|
|
|
default = "/var/lib/hound";
|
|
|
|
type = types.path;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2024-01-02 11:29:13 +00:00
|
|
|
The path to use as hound's $HOME.
|
|
|
|
If the default user "hound" is configured then this is the home of the "hound" user.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkOption {
|
|
|
|
type = types.str;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
The full configuration of the Hound daemon. Note the dbpath
|
|
|
|
should be an absolute path to a writable location on disk.
|
|
|
|
'';
|
2021-10-06 13:57:05 +00:00
|
|
|
example = literalExpression ''
|
2024-01-02 11:29:13 +00:00
|
|
|
{
|
|
|
|
"max-concurrent-indexers" : 2,
|
|
|
|
"repos" : {
|
|
|
|
"nixpkgs": {
|
|
|
|
"url" : "https://www.github.com/NixOS/nixpkgs.git"
|
|
|
|
}
|
2021-10-06 13:57:05 +00:00
|
|
|
}
|
2024-01-02 11:29:13 +00:00
|
|
|
}
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
listen = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "0.0.0.0:6080";
|
2024-01-02 11:29:13 +00:00
|
|
|
example = ":6080";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2024-01-02 11:29:13 +00:00
|
|
|
Listen on this [IP]:port
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2024-01-02 11:29:13 +00:00
|
|
|
users.groups = lib.mkIf (cfg.group == "hound") {
|
|
|
|
hound = { };
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
users.users = lib.mkIf (cfg.user == "hound") {
|
2020-04-24 23:36:52 +00:00
|
|
|
hound = {
|
2024-01-02 11:29:13 +00:00
|
|
|
description = "Hound code search";
|
2020-04-24 23:36:52 +00:00
|
|
|
createHome = true;
|
2024-01-02 11:29:13 +00:00
|
|
|
isSystemUser = true;
|
|
|
|
inherit (cfg) home group;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
systemd.services.hound = let
|
|
|
|
configFile = pkgs.writeTextFile {
|
|
|
|
name = "hound.json";
|
|
|
|
text = cfg.config;
|
|
|
|
checkPhase = ''
|
|
|
|
# check if the supplied text is valid json
|
|
|
|
${lib.getExe pkgs.jq} . $target > /dev/null
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in {
|
2020-04-24 23:36:52 +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";
|
2024-01-02 11:29:13 +00:00
|
|
|
ExecStart = "${cfg.package}/bin/houndd -addr ${cfg.listen} -conf ${configFile}";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|