nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at netboot-syslinux-multiplatform 126 lines 3.3 kB view raw
1{ config, lib, pkgs, ... }: 2with lib; 3let 4 cfg = config.services.hound; 5in { 6 options = { 7 services.hound = { 8 enable = mkOption { 9 type = types.bool; 10 default = false; 11 description = lib.mdDoc '' 12 Whether to enable the hound code search daemon. 13 ''; 14 }; 15 16 user = mkOption { 17 default = "hound"; 18 type = types.str; 19 description = lib.mdDoc '' 20 User the hound daemon should execute under. 21 ''; 22 }; 23 24 group = mkOption { 25 default = "hound"; 26 type = types.str; 27 description = lib.mdDoc '' 28 Group the hound daemon should execute under. 29 ''; 30 }; 31 32 extraGroups = mkOption { 33 type = types.listOf types.str; 34 default = [ ]; 35 example = [ "dialout" ]; 36 description = lib.mdDoc '' 37 List of extra groups that the "hound" user should be a part of. 38 ''; 39 }; 40 41 home = mkOption { 42 default = "/var/lib/hound"; 43 type = types.path; 44 description = lib.mdDoc '' 45 The path to use as hound's $HOME. If the default user 46 "hound" is configured then this is the home of the "hound" 47 user. 48 ''; 49 }; 50 51 package = mkOption { 52 default = pkgs.hound; 53 defaultText = literalExpression "pkgs.hound"; 54 type = types.package; 55 description = lib.mdDoc '' 56 Package for running hound. 57 ''; 58 }; 59 60 config = mkOption { 61 type = types.str; 62 description = lib.mdDoc '' 63 The full configuration of the Hound daemon. Note the dbpath 64 should be an absolute path to a writable location on disk. 65 ''; 66 example = literalExpression '' 67 ''' 68 { 69 "max-concurrent-indexers" : 2, 70 "dbpath" : "''${services.hound.home}/data", 71 "repos" : { 72 "nixpkgs": { 73 "url" : "https://www.github.com/NixOS/nixpkgs.git" 74 } 75 } 76 } 77 ''' 78 ''; 79 }; 80 81 listen = mkOption { 82 type = types.str; 83 default = "0.0.0.0:6080"; 84 example = "127.0.0.1:6080 or just :6080"; 85 description = lib.mdDoc '' 86 Listen on this IP:port / :port 87 ''; 88 }; 89 }; 90 }; 91 92 config = mkIf cfg.enable { 93 users.groups = optionalAttrs (cfg.group == "hound") { 94 hound.gid = config.ids.gids.hound; 95 }; 96 97 users.users = optionalAttrs (cfg.user == "hound") { 98 hound = { 99 description = "hound code search"; 100 createHome = true; 101 home = cfg.home; 102 group = cfg.group; 103 extraGroups = cfg.extraGroups; 104 uid = config.ids.uids.hound; 105 }; 106 }; 107 108 systemd.services.hound = { 109 description = "Hound Code Search"; 110 wantedBy = [ "multi-user.target" ]; 111 after = [ "network.target" ]; 112 113 serviceConfig = { 114 User = cfg.user; 115 Group = cfg.group; 116 WorkingDirectory = cfg.home; 117 ExecStartPre = "${pkgs.git}/bin/git config --global --replace-all http.sslCAinfo /etc/ssl/certs/ca-certificates.crt"; 118 ExecStart = "${cfg.package}/bin/houndd" + 119 " -addr ${cfg.listen}" + 120 " -conf ${pkgs.writeText "hound.json" cfg.config}"; 121 122 }; 123 }; 124 }; 125 126}