1import ./make-test-python.nix (
2 { pkgs, lib, ... }:
3 let
4 secret-key = "key-name:/COlMSRbehSh6YSruJWjL+R0JXQUKuPEn96fIb+pLokEJUjcK/2Gv8Ai96D7JGay5gDeUTx5wdpPgNvum9YtwA==";
5 public-key = "key-name:BCVI3Cv9hr/AIveg+yRmsuYA3lE8ecHaT4Db7pvWLcA=";
6 in
7 {
8 name = "nixseparatedebuginfod";
9 # A binary cache with debug info and source for nix
10 nodes.cache =
11 { pkgs, ... }:
12 {
13 services.nix-serve = {
14 enable = true;
15 secretKeyFile = builtins.toFile "secret-key" secret-key;
16 openFirewall = true;
17 };
18 system.extraDependencies = [
19 pkgs.nix.debug
20 pkgs.nix.src
21 pkgs.sl
22 ];
23 };
24 # the machine where we need the debuginfo
25 nodes.machine = {
26 imports = [
27 ../modules/installer/cd-dvd/channel.nix
28 ];
29 services.nixseparatedebuginfod.enable = true;
30 nix.settings = {
31 substituters = lib.mkForce [ "http://cache:5000" ];
32 trusted-public-keys = [ public-key ];
33 };
34 environment.systemPackages = [
35 pkgs.valgrind
36 pkgs.gdb
37 (pkgs.writeShellScriptBin "wait_for_indexation" ''
38 set -x
39 while debuginfod-find debuginfo /run/current-system/sw/bin/nix |& grep 'File too large'; do
40 sleep 1;
41 done
42 '')
43 ];
44 };
45 testScript = ''
46 start_all()
47 cache.wait_for_unit("nix-serve.service")
48 cache.wait_for_open_port(5000)
49 machine.wait_for_unit("nixseparatedebuginfod.service")
50 machine.wait_for_open_port(1949)
51
52 with subtest("show the config to debug the test"):
53 machine.succeed("nix --extra-experimental-features nix-command show-config |& logger")
54 machine.succeed("cat /etc/nix/nix.conf |& logger")
55 with subtest("check that the binary cache works"):
56 machine.succeed("nix-store -r ${pkgs.sl}")
57
58 # nixseparatedebuginfod needs .drv to associate executable -> source
59 # on regular systems this would be provided by nixos-rebuild
60 machine.succeed("nix-instantiate '<nixpkgs>' -A nix")
61
62 machine.succeed("timeout 600 wait_for_indexation")
63
64 # test debuginfod-find
65 machine.succeed("debuginfod-find debuginfo /run/current-system/sw/bin/nix")
66
67 # test that gdb can fetch source
68 out = machine.succeed("gdb /run/current-system/sw/bin/nix --batch -x ${builtins.toFile "commands" ''
69 start
70 l
71 ''}")
72 print(out)
73 assert 'int main(' in out
74
75 # test that valgrind can display location information
76 # this relies on the fact that valgrind complains about nix
77 # libgc helps in this regard, and we also ask valgrind to show leak kinds
78 # which are usually false positives.
79 out = machine.succeed("valgrind --leak-check=full --show-leak-kinds=all nix-env --version 2>&1")
80 print(out)
81 assert 'main.cc' in out
82 '';
83 }
84)