From 1b9fa5ade6c180b6976aa738fa1b826b607c4a74 Mon Sep 17 00:00:00 2001 From: zowoq <59103226+zowoq@users.noreply.github.com> Date: Tue, 5 Apr 2022 10:15:29 +1000 Subject: [PATCH 1/3] .github/CODEOWNERS: update dockerTools paths --- .github/CODEOWNERS | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 008d51b29aa4..07dfe176f49a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -242,9 +242,8 @@ # Docker tools /pkgs/build-support/docker @roberth -/nixos/tests/docker-tools-overlay.nix @roberth -/nixos/tests/docker-tools.nix @roberth -/doc/builders/images/dockertools.xml @roberth +/nixos/tests/docker-tools* @roberth +/doc/builders/images/dockertools.section.md @roberth # Blockchains /pkgs/applications/blockchains @mmahut @RaghavSood From 76636e00998bd095c083b107ec76a51b3c17aab1 Mon Sep 17 00:00:00 2001 From: zowoq <59103226+zowoq@users.noreply.github.com> Date: Tue, 5 Apr 2022 10:18:44 +1000 Subject: [PATCH 2/3] dockerTools: pkgs.system -> pkgs.stdenv.hostPlatform.system `pkgs.system` is an alias --- nixos/tests/docker-tools-cross.nix | 4 ++-- nixos/tests/docker-tools.nix | 2 +- pkgs/build-support/docker/examples.nix | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nixos/tests/docker-tools-cross.nix b/nixos/tests/docker-tools-cross.nix index a7a6a31475d6..8791ec258127 100644 --- a/nixos/tests/docker-tools-cross.nix +++ b/nixos/tests/docker-tools-cross.nix @@ -7,7 +7,7 @@ import ./make-test-python.nix ({ pkgs, ... }: let remoteSystem = - if pkgs.system == "aarch64-linux" + if pkgs.stdenv.hostPlatform.system == "aarch64-linux" then "x86_64-linux" else "aarch64-linux"; @@ -18,7 +18,7 @@ let # NOTE: Since this file can't control where the test will be _run_ we don't # cross-compile _to_ a different system but _from_ a different system - crossSystem = pkgs.system; + crossSystem = pkgs.stdenv.hostPlatform.system; }; hello1 = remoteCrossPkgs.dockerTools.buildImage { diff --git a/nixos/tests/docker-tools.nix b/nixos/tests/docker-tools.nix index 8a240ddb17f2..80859ac7a96e 100644 --- a/nixos/tests/docker-tools.nix +++ b/nixos/tests/docker-tools.nix @@ -315,7 +315,7 @@ import ./make-test-python.nix ({ pkgs, ... }: { "docker inspect ${pkgs.dockerTools.examples.cross.imageName} " + "| ${pkgs.jq}/bin/jq -r .[].Architecture" ).strip() - == "${if pkgs.system == "aarch64-linux" then "amd64" else "arm64"}" + == "${if pkgs.stdenv.hostPlatform.system == "aarch64-linux" then "amd64" else "arm64"}" ) with subtest("buildLayeredImage doesn't dereference /nix/store symlink layers"): diff --git a/pkgs/build-support/docker/examples.nix b/pkgs/build-support/docker/examples.nix index 941ee048666d..169edb171db4 100644 --- a/pkgs/build-support/docker/examples.nix +++ b/pkgs/build-support/docker/examples.nix @@ -486,7 +486,7 @@ rec { cross = let # Cross compile for x86_64 if on aarch64 crossPkgs = - if pkgs.system == "aarch64-linux" then pkgsCross.gnu64 + if pkgs.stdenv.hostPlatform.system == "aarch64-linux" then pkgsCross.gnu64 else pkgsCross.aarch64-multiplatform; in crossPkgs.dockerTools.buildImage { name = "hello-cross"; From e65aba25f8d8f20e83cd765e9a90b7b038f5f694 Mon Sep 17 00:00:00 2001 From: zowoq <59103226+zowoq@users.noreply.github.com> Date: Tue, 5 Apr 2022 10:18:45 +1000 Subject: [PATCH 3/3] dockerTools: misc fixes - add nixosTests to `dockerTools.tests` - don't use `pkgs` or `lib.singleton` --- pkgs/build-support/docker/default.nix | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/pkgs/build-support/docker/default.nix b/pkgs/build-support/docker/default.nix index 96ea363c811e..5a4e30ede8a3 100644 --- a/pkgs/build-support/docker/default.nix +++ b/pkgs/build-support/docker/default.nix @@ -16,8 +16,8 @@ , makeWrapper , moreutils , nix +, nixosTests , pigz -, pkgs , rsync , runCommand , runtimeShell @@ -26,6 +26,7 @@ , storeDir ? builtins.storeDir , substituteAll , symlinkJoin +, tarsum , util-linux , vmTools , writeReferencesToFile @@ -81,6 +82,15 @@ rec { inherit buildImage buildLayeredImage fakeNss pullImage shadowSetup buildImageWithNixDb; }; + tests = { + inherit (nixosTests) + docker-tools + docker-tools-overlay + # requires remote builder + # docker-tools-cross + ; + }; + pullImage = let fixName = name: builtins.replaceStrings [ "/" ":" ] [ "-" "-" ] name; @@ -113,7 +123,7 @@ rec { outputHashAlgo = "sha256"; outputHash = sha256; - nativeBuildInputs = lib.singleton skopeo; + nativeBuildInputs = [ skopeo ]; SSL_CERT_FILE = "${cacert.out}/etc/ssl/certs/ca-bundle.crt"; sourceURL = "docker://${imageName}@${imageDigest}"; @@ -132,7 +142,7 @@ rec { # We need to sum layer.tar, not a directory, hence tarsum instead of nix-hash. # And we cannot untar it, because then we cannot preserve permissions etc. - tarsum = pkgs.tarsum; + inherit tarsum; # pkgs.dockerTools.tarsum # buildEnv creates symlinks to dirs, which is hard to edit inside the overlay VM mergeDrvs = @@ -754,7 +764,7 @@ rec { # "#!/usr/bin/env executable" shebang. usrBinEnv = runCommand "usr-bin-env" { } '' mkdir -p $out/usr/bin - ln -s ${pkgs.coreutils}/bin/env $out/usr/bin + ln -s ${coreutils}/bin/env $out/usr/bin ''; # This provides /bin/sh, pointing to bashInteractive.