fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge branch 'literalExpression' [#2371]4fa1ba72

master
2.0 KiB81 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  cfg = config.services.hound;
8
9  jsonFormat = pkgs.formats.json { };
10
11  configFile = jsonFormat.generate "hound-config.json" {
12    max-concurrent-indexers = cfg.maxConcurrentIndexers;
13    dbpath = cfg.databasePath;
14    repos = cfg.repositories;
15    health-check-url = "/healthz";
16  };
17
18  houndOptions = [ "--addr ${cfg.listenAddress}" "--conf ${configFile}" ];
19
20in {
21  meta.maintainers = [ maintainers.adisbladis ];
22
23  options.services.hound = {
24    enable = mkEnableOption "hound";
25
26    maxConcurrentIndexers = mkOption {
27      type = types.ints.positive;
28      default = 2;
29      description = "Limit the amount of concurrent indexers.";
30    };
31
32    databasePath = mkOption {
33      type = types.path;
34      default = "${config.xdg.dataHome}/hound";
35      defaultText = "$XDG_DATA_HOME/hound";
36      description = "The Hound database path.";
37    };
38
39    listenAddress = mkOption {
40      type = types.str;
41      default = "localhost:6080";
42      description = "Listen address of the Hound daemon.";
43    };
44
45    repositories = mkOption {
46      type = types.attrsOf jsonFormat.type;
47      default = { };
48      example = literalExpression ''
49        {
50          SomeGitRepo = {
51            url = "https://www.github.com/YourOrganization/RepoOne.git";
52            ms-between-poll = 10000;
53            exclude-dot-files = true;
54          };
55        }
56      '';
57      description = "The repository configuration.";
58    };
59  };
60
61  config = mkIf cfg.enable {
62    assertions = [
63      (lib.hm.assertions.assertPlatform "services.hound" pkgs
64        lib.platforms.linux)
65    ];
66
67    home.packages = [ pkgs.hound ];
68
69    systemd.user.services.hound = {
70      Unit = { Description = "Hound source code search engine"; };
71
72      Install = { WantedBy = [ "default.target" ]; };
73
74      Service = {
75        Environment = "PATH=${makeBinPath [ pkgs.mercurial pkgs.git ]}";
76        ExecStart =
77          "${pkgs.hound}/bin/houndd ${concatStringsSep " " houndOptions}";
78      };
79    };
80  };
81}