summaryrefslogtreecommitdiffstats
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorBenjamin Hipple <bhipple@protonmail.com>2021-03-11 14:58:26 -0500
committerGitHub <noreply@github.com>2021-03-11 14:58:26 -0500
commit17a9f368e3519041a360285ce7a845ee36623b7d (patch)
treeb73976f9a1d3672051da26eb789e472122a94af5 /pkgs/build-support
parentf707104092b2dc70b364297826fffeed4c3968cc (diff)
parent419a4fa596577667271fcfc057bc9063ddbffe47 (diff)
Merge pull request #115793 from lbpdt/feature/docker-tools-layered-image-name-slashes
dockerTools.buildLayeredImage: image names with registry/ prefix
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/docker/default.nix12
-rw-r--r--pkgs/build-support/docker/examples.nix14
2 files changed, 21 insertions, 5 deletions
diff --git a/pkgs/build-support/docker/default.nix b/pkgs/build-support/docker/default.nix
index e0231f514a25..fec289f0ff1e 100644
--- a/pkgs/build-support/docker/default.nix
+++ b/pkgs/build-support/docker/default.nix
@@ -447,7 +447,7 @@ rec {
let
stream = streamLayeredImage args;
in
- runCommand "${name}.tar.gz" {
+ runCommand "${baseNameOf name}.tar.gz" {
inherit (stream) imageName;
passthru = { inherit (stream) imageTag; };
nativeBuildInputs = [ pigz ];
@@ -746,8 +746,10 @@ rec {
(lib.assertMsg (maxLayers > 1)
"the maxLayers argument of dockerTools.buildLayeredImage function must be greather than 1 (current value: ${toString maxLayers})");
let
+ baseName = baseNameOf name;
+
streamScript = writePython3 "stream" {} ./stream_layered_image.py;
- baseJson = writeText "${name}-base.json" (builtins.toJSON {
+ baseJson = writeText "${baseName}-base.json" (builtins.toJSON {
inherit config;
architecture = defaultArch;
os = "linux";
@@ -759,7 +761,7 @@ rec {
# things like permissions set on 'extraCommands' are not overriden
# by Nix. Then we precompute the sha256 for performance.
customisationLayer = symlinkJoin {
- name = "${name}-customisation-layer";
+ name = "${baseName}-customisation-layer";
paths = contentsList;
inherit extraCommands;
postBuild = ''
@@ -788,7 +790,7 @@ rec {
# so they'll be excluded from the created images.
unnecessaryDrvs = [ baseJson overallClosure ];
- conf = runCommand "${name}-conf.json" {
+ conf = runCommand "${baseName}-conf.json" {
inherit maxLayers created;
imageName = lib.toLower name;
passthru.imageTag =
@@ -854,7 +856,7 @@ rec {
--arg created "$created" |
tee $out
'';
- result = runCommand "stream-${name}" {
+ result = runCommand "stream-${baseName}" {
inherit (conf) imageName;
passthru = {
inherit (conf) imageTag;
diff --git a/pkgs/build-support/docker/examples.nix b/pkgs/build-support/docker/examples.nix
index 86375a40baa0..9e33a42af23e 100644
--- a/pkgs/build-support/docker/examples.nix
+++ b/pkgs/build-support/docker/examples.nix
@@ -427,4 +427,18 @@ rec {
tag = "latest";
contents = [ pkgs.bash symlink ];
} // { passthru = { inherit symlink; }; };
+
+ # image with registry/ prefix
+ prefixedImage = pkgs.dockerTools.buildImage {
+ name = "registry-1.docker.io/image";
+ tag = "latest";
+ config.Cmd = [ "${pkgs.hello}/bin/hello" ];
+ };
+
+ # layered image with registry/ prefix
+ prefixedLayeredImage = pkgs.dockerTools.buildLayeredImage {
+ name = "registry-1.docker.io/layered-image";
+ tag = "latest";
+ config.Cmd = [ "${pkgs.hello}/bin/hello" ];
+ };
}