|
15 | 15 |
|
16 | 16 | docker = pkgs.docker; |
17 | 17 |
|
| 18 | + kataShim = pkgs.writeShellApplication { |
| 19 | + name = "containerd-shim-kata-v2"; |
| 20 | + text = '' |
| 21 | + last_arg= |
| 22 | + for arg in "$@"; do |
| 23 | + last_arg="$arg" |
| 24 | + done |
| 25 | +
|
| 26 | + # Kata's standalone cleanup helper otherwise detects this |
| 27 | + # user-namespaced process as rootless and looks below /run/user/0. |
| 28 | + if [[ "$last_arg" == "delete" ]]; then |
| 29 | + export XDG_RUNTIME_DIR=/ |
| 30 | + fi |
| 31 | +
|
| 32 | + exec ${pkgs.kata-runtime}/bin/containerd-shim-kata-v2 "$@" |
| 33 | + ''; |
| 34 | + }; |
| 35 | + |
18 | 36 | jsonFormat = pkgs.formats.json { }; |
19 | 37 |
|
20 | 38 | kataKernel = import ./kernel.nix { inherit pkgs name; }; |
|
54 | 72 | substituteInPlace "$out" \ |
55 | 73 | --replace-fail \ |
56 | 74 | "$annotations_line" \ |
57 | | - 'enable_annotations = ["enable_iommu", "virtio_fs_extra_args", "kernel_params", "kernel_verity_params", "default_memory"]' |
| 75 | + 'enable_annotations = ["enable_iommu", "virtio_fs_extra_args", "kernel_params", "kernel_verity_params", "default_memory"]' \ |
| 76 | + --replace-fail \ |
| 77 | + 'sandbox_cgroup_only = false' \ |
| 78 | + 'sandbox_cgroup_only = true' |
58 | 79 | ''; |
59 | 80 |
|
60 | 81 | dockerDaemonJson = jsonFormat.generate "${name}-docker-daemon.json" { |
|
72 | 93 |
|
73 | 94 | "runtimes" = { |
74 | 95 | "kata" = { |
75 | | - "runtimeType" = "${pkgs.kata-runtime}/bin/containerd-shim-kata-v2"; |
| 96 | + "runtimeType" = "${kataShim}/bin/containerd-shim-kata-v2"; |
76 | 97 | "options" = { |
77 | 98 | "ConfigPath" = "${kataConfigToml}"; |
78 | 99 | }; |
@@ -159,9 +180,13 @@ pkgs.writeShellApplication { |
159 | 180 | docker_service_unit="${name}-docker.service" |
160 | 181 | containerd_service_unit="${name}-containerd.service" |
161 | 182 |
|
| 183 | + current_socket_link="$(readlink -f "/run/systemd/system/$docker_socket_unit" 2>/dev/null || true)" |
162 | 184 | current_service_link="$(readlink -f "/run/systemd/system/$docker_service_unit" 2>/dev/null || true)" |
| 185 | + current_containerd_link="$(readlink -f "/run/systemd/system/$containerd_service_unit" 2>/dev/null || true)" |
163 | 186 |
|
164 | | - if [[ "$current_service_link" == "${dockerSystemdServiceUnit}" ]] \ |
| 187 | + if [[ "$current_socket_link" == "${dockerSystemdSocketUnit}" ]] \ |
| 188 | + && [[ "$current_service_link" == "${dockerSystemdServiceUnit}" ]] \ |
| 189 | + && [[ "$current_containerd_link" == "${containerdServiceUnit}" ]] \ |
165 | 190 | && DOCKER_HOST="$docker_host" docker info >/dev/null 2>&1; then |
166 | 191 | emit_environment |
167 | 192 | exit 0 |
|
0 commit comments