2024-11-10 21:31:02 +00:00
|
|
|
# Test the container built by ../../docker.nix.
|
|
|
|
|
|
|
|
{ lib, config, nixpkgs, hostPkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
pkgs = config.nodes.machine.nixpkgs.pkgs;
|
|
|
|
|
|
|
|
nixImage = import ../../docker.nix {
|
|
|
|
inherit (config.nodes.machine.nixpkgs) pkgs;
|
|
|
|
};
|
|
|
|
nixUserImage = import ../../docker.nix {
|
|
|
|
inherit (config.nodes.machine.nixpkgs) pkgs;
|
|
|
|
name = "nix-user";
|
|
|
|
uid = 1000;
|
|
|
|
gid = 1000;
|
|
|
|
uname = "user";
|
|
|
|
gname = "user";
|
|
|
|
};
|
|
|
|
|
2024-11-10 23:20:31 +00:00
|
|
|
containerTestScript = ./nix-docker-test.sh;
|
|
|
|
|
2024-11-10 21:31:02 +00:00
|
|
|
in {
|
|
|
|
name = "nix-docker";
|
|
|
|
|
2024-11-10 23:20:31 +00:00
|
|
|
nodes =
|
|
|
|
{ machine =
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
{ virtualisation.diskSize = 4096;
|
|
|
|
};
|
|
|
|
cache =
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
{ virtualisation.additionalPaths = [ pkgs.stdenv pkgs.hello ];
|
|
|
|
services.harmonia.enable = true;
|
|
|
|
networking.firewall.allowedTCPPorts = [ 5000 ];
|
|
|
|
};
|
2024-11-10 21:31:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
testScript = { nodes }: ''
|
2024-11-10 23:20:31 +00:00
|
|
|
cache.wait_for_unit("harmonia.service")
|
|
|
|
|
2024-11-10 21:31:02 +00:00
|
|
|
machine.succeed("mkdir -p /etc/containers")
|
|
|
|
machine.succeed("""echo '{"default":[{"type":"insecureAcceptAnything"}]}' > /etc/containers/policy.json""")
|
|
|
|
|
|
|
|
machine.succeed("${pkgs.podman}/bin/podman load -i ${nixImage}")
|
|
|
|
machine.succeed("${pkgs.podman}/bin/podman run --rm nix nix --version")
|
2024-11-10 23:20:31 +00:00
|
|
|
machine.succeed("${pkgs.podman}/bin/podman run --rm -i nix < ${containerTestScript}")
|
2024-11-10 21:31:02 +00:00
|
|
|
|
|
|
|
machine.succeed("${pkgs.podman}/bin/podman load -i ${nixUserImage}")
|
|
|
|
machine.succeed("${pkgs.podman}/bin/podman run --rm nix-user nix --version")
|
2024-11-10 23:20:31 +00:00
|
|
|
machine.succeed("${pkgs.podman}/bin/podman run --rm -i nix-user < ${containerTestScript}")
|
2024-11-10 21:31:02 +00:00
|
|
|
machine.succeed("[[ $(${pkgs.podman}/bin/podman run --rm nix-user stat -c %u /nix/store) = 1000 ]]")
|
|
|
|
'';
|
|
|
|
}
|