nixpkgs/nixos/tests/nixseparatedebuginfod.nix
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00

85 lines
2.8 KiB
Nix

import ./make-test-python.nix (
{ pkgs, lib, ... }:
let
secret-key = "key-name:/COlMSRbehSh6YSruJWjL+R0JXQUKuPEn96fIb+pLokEJUjcK/2Gv8Ai96D7JGay5gDeUTx5wdpPgNvum9YtwA==";
public-key = "key-name:BCVI3Cv9hr/AIveg+yRmsuYA3lE8ecHaT4Db7pvWLcA=";
in
{
name = "nixseparatedebuginfod";
# A binary cache with debug info and source for nix
nodes.cache =
{ pkgs, ... }:
{
services.nix-serve = {
enable = true;
secretKeyFile = builtins.toFile "secret-key" secret-key;
openFirewall = true;
};
system.extraDependencies = [
pkgs.nix.debug
pkgs.nix.src
pkgs.sl
];
};
# the machine where we need the debuginfo
nodes.machine = {
imports = [
../modules/installer/cd-dvd/channel.nix
];
services.nixseparatedebuginfod.enable = true;
nix.settings = {
substituters = lib.mkForce [ "http://cache:5000" ];
trusted-public-keys = [ public-key ];
};
environment.systemPackages = [
pkgs.valgrind
pkgs.gdb
(pkgs.writeShellScriptBin "wait_for_indexation" ''
set -x
while debuginfod-find debuginfo /run/current-system/sw/bin/nix |& grep 'File too large'; do
sleep 1;
done
'')
];
};
testScript = ''
start_all()
cache.wait_for_unit("nix-serve.service")
cache.wait_for_open_port(5000)
machine.wait_for_unit("nixseparatedebuginfod.service")
machine.wait_for_open_port(1949)
with subtest("show the config to debug the test"):
machine.succeed("nix --extra-experimental-features nix-command show-config |& logger")
machine.succeed("cat /etc/nix/nix.conf |& logger")
with subtest("check that the binary cache works"):
machine.succeed("nix-store -r ${pkgs.sl}")
# nixseparatedebuginfod needs .drv to associate executable -> source
# on regular systems this would be provided by nixos-rebuild
machine.succeed("nix-instantiate '<nixpkgs>' -A nix")
machine.succeed("timeout 600 wait_for_indexation")
# test debuginfod-find
machine.succeed("debuginfod-find debuginfo /run/current-system/sw/bin/nix")
# test that gdb can fetch source
out = machine.succeed("gdb /run/current-system/sw/bin/nix --batch -x ${builtins.toFile "commands" ''
start
l
''}")
print(out)
assert 'int main(' in out
# test that valgrind can display location information
# this relies on the fact that valgrind complains about nix
# libgc helps in this regard, and we also ask valgrind to show leak kinds
# which are usually false positives.
out = machine.succeed("valgrind --leak-check=full --show-leak-kinds=all nix-env --version 2>&1")
print(out)
assert 'main.cc' in out
'';
}
)