Skip to content

Commit b6705e9

Browse files
pietroalbinisyphar
authored andcommitted
fix running tests inside of nixos
1 parent 8330f60 commit b6705e9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/buildtest/inside_docker.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ fn execute(test: &str) -> anyhow::Result<()> {
4343
let target_mount = os_string!(&target_parent_dir, ":", &target_prefix);
4444
let docker_sock = os_string!(DOCKER_SOCKET, ":", DOCKER_SOCKET);
4545

46+
// NixOS's linkage model is different compared to any other Linux distribution, as it stores
47+
// all of the shared libraries it links to in /nix. Mounting that directory inside the
48+
// container allows the test binary to be executed inside of the container.
49+
let nixos_args: &[&str] = if std::fs::exists("/nix")? {
50+
&["-v", "/nix:/nix:ro"]
51+
} else {
52+
&[]
53+
};
54+
4655
Command::new("docker")
4756
.arg("run")
4857
.arg("-v")
@@ -51,6 +60,7 @@ fn execute(test: &str) -> anyhow::Result<()> {
5160
.arg(target_mount)
5261
.arg("-v")
5362
.arg(docker_sock)
63+
.args(nixos_args)
5464
.arg("-w")
5565
.arg(container_prefix)
5666
.arg("-e")

0 commit comments

Comments
 (0)