aboutsummaryrefslogtreecommitdiff
path: root/tests/nixos/symlink-resolvconf.nix
blob: 6a7d24601833de99838e6ed7bc0c4941b33b71d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{ pkgs, ... }:
let
  # Can't use the cool helper because inputDerivation does not work with FODs :(
  checkResolvconfInSandbox = pkgs.runCommand "resolvconf-works-in-sandbox" {
    # must be an FOD to have a resolv.conf in the first place
    outputHash = "sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=";
    outputHashAlgo = "sha256";
    outputHashType = "flat";
  } ''
    cat /etc/resolv.conf
    touch $out
  '';
in {
  name = "symlink-resolvconf";

  nodes.machine = {
    # Enabling resolved makes /etc/resolv.conf a symlink to /etc/static/resolv.conf, which is itself a symlink to /run.
    # If this works, most other things probably will too.
    services.resolved.enable = true;

    virtualisation.additionalPaths = [checkResolvconfInSandbox.drvPath];
  };

  testScript = { nodes }: ''
    start_all()

    machine.succeed('nix-build --check ${checkResolvconfInSandbox.drvPath}')
  '';
}