1# Test whether `houndd` indexes nixpkgs
2{ pkgs, ... }:
3{
4 name = "hound";
5 meta = with pkgs.lib.maintainers; {
6 maintainers = [ grahamc ];
7 };
8 nodes.machine =
9 { pkgs, ... }:
10 {
11 services.hound = {
12 enable = true;
13 settings = {
14 "max-concurrent-indexers" = 1;
15 "dbpath" = "/var/lib/hound/data";
16 "repos" = {
17 "nix" = {
18 "url" = "file:///var/lib/hound/my-git";
19 };
20 };
21 };
22 };
23
24 systemd.services.houndseed = {
25 description = "seed hound with a git repo";
26 requiredBy = [ "hound.service" ];
27 before = [ "hound.service" ];
28
29 serviceConfig = {
30 User = "hound";
31 Group = "hound";
32 WorkingDirectory = "/var/lib/hound";
33 };
34 path = [ pkgs.git ];
35 script = ''
36 git config --global user.email "you@example.com"
37 git config --global user.name "Your Name"
38 git init my-git --bare
39 git init my-git-clone
40 cd my-git-clone
41 echo 'hi nix!' > hello
42 git add hello
43 git commit -m "hello there :)"
44 git remote add origin /var/lib/hound/my-git
45 git push origin master
46 '';
47 };
48 };
49
50 testScript = ''
51 start_all()
52
53 machine.wait_for_unit("network.target")
54 machine.wait_for_unit("hound.service")
55 machine.wait_for_open_port(6080)
56 machine.wait_until_succeeds(
57 "curl -f http://127.0.0.1:6080/api/v1/search\?stats\=fosho\&repos\=\*\&rng=%3A20\&q\=hi\&files\=\&i=nope | grep 'Filename' | grep 'hello'"
58 )
59 '';
60}