So I’m doing a little NixOS test and I’d like it to have internet connection (I know this is not a good practice but this is just for testing my way around). I’ve read here that you just have to disable the nix sandbox. So I put
machine # ping: google.com: Name or service not known
Am I missing something?
As an aside, It may be wrong to hijack my own question like this but I feel it’s wronger to open a new one just for this: How would I use shell_interact() when launching the test from a flake?
I run my test from a flake output as nix build .#nixosTests.test -L but then a shell_interact() gives me
Any hint for this one is welcome since I’m still stuck and have no idea what to try next. Here’s a very small code sample that illustrates my problem:
{ pkgs, ... }:
pkgs.nixosTest {
name = "internetTest";
machine = { pkgs, ... }: {
nix.useSandbox = false;
};
testScript = ''
machine.wait_for_unit("default.target")
machine.succeed("ping -c1 142.250.184.174") # the ip I got from "ping google.com", in case it's something related to DNS
'';
}
I’ve long ditched that configuration, but IIRC the sandbox is actually a configuration of your host nix, not the virtual machine launched for the test. So nix.useSandbox = false should go to your system-wide nix configuration, that is:
/etc/nixos/configuration.nix for NixOS
nix.conf otherwise (though I think the option is just sandbox there, but I only use NixOS)