···55in
66{
77 name = "nixseparatedebuginfod";
88- # A binary cache with debug info and source for nix
88+ # A binary cache with debug info and source for gnumake
99 nodes.cache =
1010 { pkgs, ... }:
1111 {
···1515 openFirewall = true;
1616 };
1717 system.extraDependencies = [
1818- pkgs.nix.debug
1919- pkgs.nix.src
1818+ pkgs.gnumake.debug
1919+ pkgs.gnumake.src
2020 pkgs.sl
2121 ];
2222 };
···3333 environment.systemPackages = [
3434 pkgs.valgrind
3535 pkgs.gdb
3636+ pkgs.gnumake
3637 (pkgs.writeShellScriptBin "wait_for_indexation" ''
3738 set -x
3838- while debuginfod-find debuginfo /run/current-system/sw/bin/nix |& grep 'File too large'; do
3939+ while debuginfod-find debuginfo /run/current-system/sw/bin/make |& grep 'File too large'; do
3940 sleep 1;
4041 done
4142 '')
···56575758 # nixseparatedebuginfod needs .drv to associate executable -> source
5859 # on regular systems this would be provided by nixos-rebuild
5959- machine.succeed("nix-instantiate '<nixpkgs>' -A nix")
6060+ machine.succeed("nix-instantiate '<nixpkgs>' -A gnumake")
60616162 machine.succeed("timeout 600 wait_for_indexation")
62636364 # test debuginfod-find
6464- machine.succeed("debuginfod-find debuginfo /run/current-system/sw/bin/nix")
6565+ machine.succeed("debuginfod-find debuginfo /run/current-system/sw/bin/make")
65666667 # test that gdb can fetch source
6767- out = machine.succeed("gdb /run/current-system/sw/bin/nix --batch -x ${builtins.toFile "commands" ''
6868+ out = machine.succeed("gdb /run/current-system/sw/bin/make --batch -x ${builtins.toFile "commands" ''
6869 start
6970 l
7071 ''}")
7172 print(out)
7272- assert 'int main(' in out
7373+ assert 'main (int argc, char **argv, char **envp)' in out
73747475 # test that valgrind can display location information
7575- # this relies on the fact that valgrind complains about nix
7676- # libgc helps in this regard, and we also ask valgrind to show leak kinds
7676+ # this relies on the fact that valgrind complains about gnumake
7777+ # because we also ask valgrind to show leak kinds
7778 # which are usually false positives.
7878- out = machine.succeed("valgrind --leak-check=full --show-leak-kinds=all nix-env --version 2>&1")
7979+ out = machine.succeed("valgrind --leak-check=full --show-leak-kinds=all make --version 2>&1")
7980 print(out)
8080- assert 'main.cc' in out
8181+ assert 'main.c' in out
8182 '';
8283}
+72
nixos/tests/nixseparatedebuginfod2.nix
···11+{ pkgs, lib, ... }:
22+{
33+ name = "nixseparatedebuginfod2";
44+ # A binary cache with debug info and source for gnumake
55+ nodes.cache =
66+ { pkgs, ... }:
77+ {
88+ services.nginx = {
99+ enable = true;
1010+ virtualHosts.default = {
1111+ default = true;
1212+ addSSL = false;
1313+ root = "/var/lib/thebinarycache";
1414+ };
1515+ };
1616+ networking.firewall.allowedTCPPorts = [ 80 ];
1717+ systemd.services.buildthebinarycache = {
1818+ before = [ "nginx.service" ];
1919+ wantedBy = [ "nginx.service" ];
2020+ script = ''
2121+ ${pkgs.nix}/bin/nix --extra-experimental-features nix-command copy --to file:///var/lib/thebinarycache?index-debug-info=true ${pkgs.gnumake.debug} ${pkgs.gnumake} ${pkgs.gnumake.src} ${pkgs.sl}
2222+ '';
2323+ serviceConfig = {
2424+ User = "nginx";
2525+ Group = "nginx";
2626+ StateDirectory = "thebinarycache";
2727+ Type = "oneshot";
2828+ };
2929+ };
3030+ };
3131+ # the machine where we need the debuginfo
3232+ nodes.machine = {
3333+ services.nixseparatedebuginfod2 = {
3434+ enable = true;
3535+ substituter = "http://cache";
3636+ };
3737+ environment.systemPackages = [
3838+ pkgs.valgrind
3939+ pkgs.gdb
4040+ pkgs.gnumake
4141+ ];
4242+ };
4343+ testScript = ''
4444+ start_all()
4545+ cache.wait_for_unit("nginx.service")
4646+ cache.wait_for_open_port(80)
4747+ machine.wait_for_unit("nixseparatedebuginfod2.service")
4848+ machine.wait_for_open_port(1950)
4949+5050+ with subtest("check that the binary cache works"):
5151+ machine.succeed("nix-store --extra-substituters http://cache --option require-sigs false -r ${pkgs.sl}")
5252+5353+ # test debuginfod-find
5454+ machine.succeed("debuginfod-find debuginfo /run/current-system/sw/bin/make")
5555+5656+ # test that gdb can fetch source
5757+ out = machine.succeed("gdb /run/current-system/sw/bin/make --batch -x ${builtins.toFile "commands" ''
5858+ start
5959+ l
6060+ ''}")
6161+ print(out)
6262+ assert 'main (int argc, char **argv, char **envp)' in out
6363+6464+ # test that valgrind can display location information
6565+ # this relies on the fact that valgrind complains about gnumake
6666+ # because we also ask valgrind to show leak kinds
6767+ # which are usually false positives.
6868+ out = machine.succeed("valgrind --leak-check=full --show-leak-kinds=all make --version 2>&1")
6969+ print(out)
7070+ assert 'main.c' in out
7171+ '';
7272+}