Skip to content
This repository was archived by the owner on Apr 12, 2021. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs-channels
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 74fe437075bd
Choose a base ref
...
head repository: NixOS/nixpkgs-channels
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: af7d54e97227
Choose a head ref
  • 9 commits
  • 12 files changed
  • 6 contributors

Commits on Oct 27, 2018

  1. dockertools: tarsum: turn in to a buildInput

    (cherry picked from commit 2bf0ee3)
    graham-at-target authored and flokli committed Oct 27, 2018

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    marsam Mario Rodas
    Copy the full SHA
    607e614 View commit details
  2. referencesByPopularity: init to sort packages by a cachability heuristic

    Using a simple algorithm, convert the references to a path in to a
    sorted list of dependent paths based on how often they're referenced
    and how deep in the tree they live. Equally-"popular" paths are then
    sorted by name.
    
    The existing writeReferencesToFile prints the paths in a simple
    ascii-based sorting of the paths.
    
    Sorting the paths by graph improves the chances that the difference
    between two builds appear near the end of the list, instead of near
    the beginning. This makes a difference for Nix builds which export a
    closure for another program to consume, if that program implements its
    own level of binary diffing.
    
    For an example, Docker Images. If each store path is a separate layer
    then Docker Images can be very efficiently transfered between systems,
    and we get very good cache reuse between images built with the same
    version of Nixpkgs. However, since Docker only reliably supports a
    small number of layers (42) it is important to pick the individual
    layers carefully. By storing very popular store paths in the first 40
    layers, we improve the chances that the next Docker image will share
    many of those layers.*
    
    Given the dependency tree:
    
        A - B - C - D -\
         \   \   \      \
          \   \   \      \
           \   \ - E ---- F
            \- G
    
    Nodes which have multiple references are duplicated:
    
        A - B - C - D - F
         \   \   \
          \   \   \- E - F
           \   \
            \   \- E - F
             \
              \- G
    
    Each leaf node is now replaced by a counter defaulted to 1:
    
        A - B - C - D - (F:1)
         \   \   \
          \   \   \- E - (F:1)
           \   \
            \   \- E - (F:1)
             \
              \- (G:1)
    
    Then each leaf counter is merged with its parent node, replacing the
    parent node with a counter of 1, and each existing counter being
    incremented by 1. That is to say `- D - (F:1)` becomes `- (D:1, F:2)`:
    
        A - B - C - (D:1, F:2)
         \   \   \
          \   \   \- (E:1, F:2)
           \   \
            \   \- (E:1, F:2)
             \
              \- (G:1)
    
    Then each leaf counter is merged with its parent node again, merging
    any counters, then incrementing each:
    
        A - B - (C:1, D:2, E:2, F:5)
         \   \
          \   \- (E:1, F:2)
           \
            \- (G:1)
    
    And again:
    
        A - (B:1, C:2, D:3, E:4, F:8)
         \
          \- (G:1)
    
    And again:
    
        (A:1, B:2, C:3, D:4, E:5, F:9, G:2)
    
    and then paths have the following "popularity":
    
        A     1
        B     2
        C     3
        D     4
        E     5
        F     9
        G     2
    
    and the popularity contest would result in the paths being printed as:
    
        F
        E
        D
        C
        B
        G
        A
    
    * Note: People who have used a Dockerfile before assume Docker's
    Layers are inherently ordered. However, this is not true -- Docker
    layers are content-addressable and are not explicitly layered until
    they are composed in to an Image.
    
    (cherry picked from commit fd04517)
    graham-at-target authored and flokli committed Oct 27, 2018

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    marsam Mario Rodas
    Copy the full SHA
    61b4fa9 View commit details
  3. dockerTools.buildLayeredImage: init

    Create a many-layered Docker Image.
    
    Implements much less than buildImage:
    
     - Doesn't support specific uids/gids
     - Doesn't support runninng commands after building
     - Doesn't require qemu
     - Doesn't create mutable copies of the files in the path
     - Doesn't support parent images
    
    If you want those feature, I recommend using buildLayeredImage as an
    input to buildImage.
    
    Notably, it does support:
    
     - Caching low level, common paths based on a graph traversial
       algorithm, see referencesByPopularity in
       0a80233487993256e811f566b1c80a40394c03d6
     - Configurable number of layers. If you're not using AUFS or not
       extending the image, you can specify a larger number of layers at
       build time:
    
           pkgs.dockerTools.buildLayeredImage {
             name = "hello";
             maxLayers = 128;
             config.Cmd = [ "${pkgs.gitFull}/bin/git" ];
           };
    
     - Parallelized creation of the layers, improving build speed.
     - The contents of the image includes the closure of the configuration,
       so you don't have to specify paths in contents and config.
    
       With buildImage, paths referred to by the config were not included
       automatically in the image. Thus, if you wanted to call Git, you
       had to specify it twice:
    
           pkgs.dockerTools.buildImage {
             name = "hello";
             contents = [ pkgs.gitFull ];
             config.Cmd = [ "${pkgs.gitFull}/bin/git" ];
           };
    
       buildLayeredImage on the other hand includes the runtime closure of
       the config when calculating the contents of the image:
    
           pkgs.dockerTools.buildImage {
             name = "hello";
             config.Cmd = [ "${pkgs.gitFull}/bin/git" ];
           };
    
    Minor Problems
    
     - If any of the store paths change, every layer will be rebuilt in
       the nix-build. However, beacuse the layers are bit-for-bit
       reproducable, when these images are loaded in to Docker they will
       match existing layers and not be imported or uploaded twice.
    
    Common Questions
    
     - Aren't Docker layers ordered?
    
       No. People who have used a Dockerfile before assume Docker's
       Layers are inherently ordered. However, this is not true -- Docker
       layers are content-addressable and are not explicitly layered until
       they are composed in to an Image.
    
     - What happens if I have more than maxLayers of store paths?
    
       The first (maxLayers-2) most "popular" paths will have their own
       individual layers, then layer #(maxLayers-1) will contain all the
       remaining "unpopular" paths, and finally layer #(maxLayers) will
       contain the Image configuration.
    
    (cherry picked from commit 4fe9006)
    (cherry picked from commit d1e46df)
    graham-at-target authored and flokli committed Oct 27, 2018
    Copy the full SHA
    fbb61c1 View commit details
  4. dockerTools: test buildLayeredImage

    (cherry picked from commit fb2d153)
    grahamc authored and flokli committed Oct 27, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    5a4f330 View commit details

Commits on Oct 29, 2018

  1. Merge pull request #49240 from flokli/layered-docker-images-18.09

    [18.09] layered docker images
    flokli authored Oct 29, 2018
    Copy the full SHA
    ec6af33 View commit details
  2. clamav: 0.100.1 -> 0.100.2

    Semi-automatic update generated by
    https://github.com/ryantm/nixpkgs-update tools. This update was made
    based on information from
    https://repology.org/metapackage/clamav/versions
    
    (cherry picked from commit b249bcc)
    r-ryantm authored and bjornfor committed Oct 29, 2018
    Copy the full SHA
    d5814e2 View commit details
  3. gitlab: 11.4.0 -> 11.4.3

    (cherry picked from commit 3aec530)
    globin committed Oct 29, 2018
    Copy the full SHA
    bf392fe View commit details
  4. matomo: 3.6.0 -> 3.6.1

    Semi-automatic update generated by
    https://github.com/ryantm/nixpkgs-update tools. This update was made
    based on information from
    https://repology.org/metapackage/matomo/versions
    
    (cherry picked from commit d4029e7)
    r-ryantm authored and timokau committed Oct 29, 2018
    Copy the full SHA
    68cf714 View commit details
  5. crystal: fix "play" subcommand (#49422)

    (backport of commit 473c890)
    zarelit authored and xeji committed Oct 29, 2018

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    af7d54e View commit details
277 changes: 224 additions & 53 deletions doc/functions/dockertools.xml
Original file line number Diff line number Diff line change
@@ -37,29 +37,29 @@
<example xml:id='ex-dockerTools-buildImage'>
<title>Docker build</title>
<programlisting>
buildImage {
name = "redis"; <co xml:id='ex-dockerTools-buildImage-1' />
tag = "latest"; <co xml:id='ex-dockerTools-buildImage-2' />

fromImage = someBaseImage; <co xml:id='ex-dockerTools-buildImage-3' />
fromImageName = null; <co xml:id='ex-dockerTools-buildImage-4' />
fromImageTag = "latest"; <co xml:id='ex-dockerTools-buildImage-5' />

contents = pkgs.redis; <co xml:id='ex-dockerTools-buildImage-6' />
runAsRoot = '' <co xml:id='ex-dockerTools-buildImage-runAsRoot' />
#!${stdenv.shell}
mkdir -p /data
'';

config = { <co xml:id='ex-dockerTools-buildImage-8' />
Cmd = [ "/bin/redis-server" ];
WorkingDir = "/data";
Volumes = {
"/data" = {};
};
buildImage {
name = "redis"; <co xml:id='ex-dockerTools-buildImage-1' />
tag = "latest"; <co xml:id='ex-dockerTools-buildImage-2' />

fromImage = someBaseImage; <co xml:id='ex-dockerTools-buildImage-3' />
fromImageName = null; <co xml:id='ex-dockerTools-buildImage-4' />
fromImageTag = "latest"; <co xml:id='ex-dockerTools-buildImage-5' />

contents = pkgs.redis; <co xml:id='ex-dockerTools-buildImage-6' />
runAsRoot = '' <co xml:id='ex-dockerTools-buildImage-runAsRoot' />
#!${stdenv.shell}
mkdir -p /data
'';

config = { <co xml:id='ex-dockerTools-buildImage-8' />
Cmd = [ "/bin/redis-server" ];
WorkingDir = "/data";
Volumes = {
"/data" = {};
};
}
</programlisting>
};
}
</programlisting>
</example>

<para>
@@ -226,6 +226,177 @@ hello latest de2bf4786de6 About a minute ago 25.2MB
</example>
</section>

<section xml:id="ssec-pkgs-dockerTools-buildLayeredImage">
<title>buildLayeredImage</title>

<para>
Create a Docker image with many of the store paths being on their own layer
to improve sharing between images.
</para>

<variablelist>
<varlistentry>
<term>
<varname>name</varname>
</term>
<listitem>
<para>
The name of the resulting image.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<varname>tag</varname> <emphasis>optional</emphasis>
</term>
<listitem>
<para>
Tag of the generated image.
</para>
<para>
<emphasis>Default:</emphasis> the output path's hash
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<varname>contents</varname> <emphasis>optional</emphasis>
</term>
<listitem>
<para>
Top level paths in the container. Either a single derivation, or a list
of derivations.
</para>
<para>
<emphasis>Default:</emphasis> <literal>[]</literal>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<varname>config</varname> <emphasis>optional</emphasis>
</term>
<listitem>
<para>
Run-time configuration of the container. A full list of the options are
available at in the
<link xlink:href="https://github.com/moby/moby/blob/master/image/spec/v1.2.md#image-json-field-descriptions">
Docker Image Specification v1.2.0 </link>.
</para>
<para>
<emphasis>Default:</emphasis> <literal>{}</literal>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<varname>created</varname> <emphasis>optional</emphasis>
</term>
<listitem>
<para>
Date and time the layers were created. Follows the same
<literal>now</literal> exception supported by
<literal>buildImage</literal>.
</para>
<para>
<emphasis>Default:</emphasis> <literal>1970-01-01T00:00:01Z</literal>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<varname>maxLayers</varname> <emphasis>optional</emphasis>
</term>
<listitem>
<para>
Maximum number of layers to create.
</para>
<para>
<emphasis>Default:</emphasis> <literal>24</literal>
</para>
</listitem>
</varlistentry>
</variablelist>

<section xml:id="dockerTools-buildLayeredImage-arg-contents">
<title>Behavior of <varname>contents</varname> in the final image</title>

<para>
Each path directly listed in <varname>contents</varname> will have a
symlink in the root of the image.
</para>

<para>
For example:
<programlisting><![CDATA[
pkgs.dockerTools.buildLayeredImage {
name = "hello";
contents = [ pkgs.hello ];
}
]]></programlisting>
will create symlinks for all the paths in the <literal>hello</literal>
package:
<screen><![CDATA[
/bin/hello -> /nix/store/h1zb1padqbbb7jicsvkmrym3r6snphxg-hello-2.10/bin/hello
/share/info/hello.info -> /nix/store/h1zb1padqbbb7jicsvkmrym3r6snphxg-hello-2.10/share/info/hello.info
/share/locale/bg/LC_MESSAGES/hello.mo -> /nix/store/h1zb1padqbbb7jicsvkmrym3r6snphxg-hello-2.10/share/locale/bg/LC_MESSAGES/hello.mo
]]></screen>
</para>
</section>

<section xml:id="dockerTools-buildLayeredImage-arg-config">
<title>Automatic inclusion of <varname>config</varname> references</title>

<para>
The closure of <varname>config</varname> is automatically included in the
closure of the final image.
</para>

<para>
This allows you to make very simple Docker images with very little code.
This container will start up and run <command>hello</command>:
<programlisting><![CDATA[
pkgs.dockerTools.buildLayeredImage {
name = "hello";
config.Cmd = [ "${pkgs.hello}/bin/hello" ];
}
]]></programlisting>
</para>
</section>

<section xml:id="dockerTools-buildLayeredImage-arg-maxLayers">
<title>Adjusting <varname>maxLayers</varname></title>

<para>
Increasing the <varname>maxLayers</varname> increases the number of layers
which have a chance to be shared between different images.
</para>

<para>
Modern Docker installations support up to 128 layers, however older
versions support as few as 42.
</para>

<para>
If the produced image will not be extended by other Docker builds, it is
safe to set <varname>maxLayers</varname> to <literal>128</literal>. However
it will be impossible to extend the image further.
</para>

<para>
The first (<literal>maxLayers-2</literal>) most "popular" paths will have
their own individual layers, then layer #<literal>maxLayers-1</literal>
will contain all the remaining "unpopular" paths, and finally layer
#<literal>maxLayers</literal> will contain the Image configuration.
</para>

<para>
Docker's Layers are not inherently ordered, they are content-addressable
and are not explicitly layered until they are composed in to an Image.
</para>
</section>
</section>

<section xml:id="ssec-pkgs-dockerTools-fetchFromRegistry">
<title>pullImage</title>

@@ -243,15 +414,15 @@ hello latest de2bf4786de6 About a minute ago 25.2MB
<example xml:id='ex-dockerTools-pullImage'>
<title>Docker pull</title>
<programlisting>
pullImage {
imageName = "nixos/nix"; <co xml:id='ex-dockerTools-pullImage-1' />
imageDigest = "sha256:20d9485b25ecfd89204e843a962c1bd70e9cc6858d65d7f5fadc340246e2116b"; <co xml:id='ex-dockerTools-pullImage-2' />
finalImageTag = "1.11"; <co xml:id='ex-dockerTools-pullImage-3' />
sha256 = "0mqjy3zq2v6rrhizgb9nvhczl87lcfphq9601wcprdika2jz7qh8"; <co xml:id='ex-dockerTools-pullImage-4' />
os = "linux"; <co xml:id='ex-dockerTools-pullImage-5' />
arch = "x86_64"; <co xml:id='ex-dockerTools-pullImage-6' />
}
</programlisting>
pullImage {
imageName = "nixos/nix"; <co xml:id='ex-dockerTools-pullImage-1' />
imageDigest = "sha256:20d9485b25ecfd89204e843a962c1bd70e9cc6858d65d7f5fadc340246e2116b"; <co xml:id='ex-dockerTools-pullImage-2' />
finalImageTag = "1.11"; <co xml:id='ex-dockerTools-pullImage-3' />
sha256 = "0mqjy3zq2v6rrhizgb9nvhczl87lcfphq9601wcprdika2jz7qh8"; <co xml:id='ex-dockerTools-pullImage-4' />
os = "linux"; <co xml:id='ex-dockerTools-pullImage-5' />
arch = "x86_64"; <co xml:id='ex-dockerTools-pullImage-6' />
}
</programlisting>
</example>

<calloutlist>
@@ -273,9 +444,9 @@ hello latest de2bf4786de6 About a minute ago 25.2MB
exactly which image you want. By default it will match the OS and
architecture of the host the command is run on.
<programlisting>
$ nix-shell --packages skopeo jq --command "skopeo --override-os linux --override-arch x86_64 inspect docker://docker.io/nixos/nix:1.11 | jq -r '.Digest'"
sha256:20d9485b25ecfd89204e843a962c1bd70e9cc6858d65d7f5fadc340246e2116b
</programlisting>
$ nix-shell --packages skopeo jq --command "skopeo --override-os linux --override-arch x86_64 inspect docker://docker.io/nixos/nix:1.11 | jq -r '.Digest'"
sha256:20d9485b25ecfd89204e843a962c1bd70e9cc6858d65d7f5fadc340246e2116b
</programlisting>
This argument is required.
</para>
</callout>
@@ -333,13 +504,13 @@ hello latest de2bf4786de6 About a minute ago 25.2MB
<example xml:id='ex-dockerTools-exportImage'>
<title>Docker export</title>
<programlisting>
exportImage {
fromImage = someLayeredImage;
fromImageName = null;
fromImageTag = null;
exportImage {
fromImage = someLayeredImage;
fromImageName = null;
fromImageTag = null;

name = someLayeredImage.name;
}
name = someLayeredImage.name;
}
</programlisting>
</example>

@@ -369,19 +540,19 @@ hello latest de2bf4786de6 About a minute ago 25.2MB
<example xml:id='ex-dockerTools-shadowSetup'>
<title>Shadow base files</title>
<programlisting>
buildImage {
name = "shadow-basic";

runAsRoot = ''
#!${stdenv.shell}
${shadowSetup}
groupadd -r redis
useradd -r -g redis redis
mkdir /data
chown redis:redis /data
'';
}
</programlisting>
buildImage {
name = "shadow-basic";

runAsRoot = ''
#!${stdenv.shell}
${shadowSetup}
groupadd -r redis
useradd -r -g redis redis
mkdir /data
chown redis:redis /data
'';
}
</programlisting>
</example>

<para>
4 changes: 4 additions & 0 deletions nixos/tests/docker-tools.nix
Original file line number Diff line number Diff line change
@@ -58,5 +58,9 @@ import ./make-test.nix ({ pkgs, ... }: {
# Ensure Docker images can use an unstable date
$docker->succeed("docker load --input='${pkgs.dockerTools.examples.bash}'");
$docker->succeed("[ '1970-01-01T00:00:01Z' != \"\$(docker inspect ${pkgs.dockerTools.examples.unstableDate.imageName} | ${pkgs.jq}/bin/jq -r .[].Created)\" ]");
# Ensure Layered Docker images work
$docker->succeed("docker load --input='${pkgs.dockerTools.examples.layered-image}'");
$docker->succeed("docker run --rm ${pkgs.dockerTools.examples.layered-image.imageName}");
'';
})
10 changes: 5 additions & 5 deletions pkgs/applications/version-management/gitlab/default.nix
Original file line number Diff line number Diff line change
@@ -11,29 +11,29 @@ let
groups = [ "default" "unicorn" "ed25519" "metrics" ];
};

version = "11.4.0";
version = "11.4.3";

sources = if gitlabEnterprise then {
gitlabDeb = fetchurl {
url = "https://packages.gitlab.com/gitlab/gitlab-ee/packages/debian/stretch/gitlab-ee_${version}-ee.0_amd64.deb/download.deb";
sha256 = "1y2a8acgsgrgcjazijsflhxq4fwqvd9yhrjx5pcncb24vl0x6dg4";
sha256 = "1cw75qj508z6n00rqgqjzdm2013kyb7c57cypmq0m08nc6f3jspz";
};
gitlab = fetchFromGitLab {
owner = "gitlab-org";
repo = "gitlab-ee";
rev = "v${version}-ee";
sha256 = "1pyqk1c5bml7chs4pq1fcxkrhk5r327xx9my6zmp2cb503s5m590";
sha256 = "1vqc77whpbsifbm9vgcmpxnw13v8jz1s9q04i8jfv99c59fjlids";
};
} else {
gitlabDeb = fetchurl {
url = "https://packages.gitlab.com/gitlab/gitlab-ce/packages/debian/stretch/gitlab-ce_${version}-ce.0_amd64.deb/download.deb";
sha256 = "0wiizjihn1a6hg6a2wpwmnh5a34n102va4djac3sgx74mwx4bniq";
sha256 = "0vk03k42pp92h520wnynl9czcigjhj9m7y68z1x0gwqr9m61r7zm";
};
gitlab = fetchFromGitLab {
owner = "gitlab-org";
repo = "gitlab-ce";
rev = "v${version}";
sha256 = "1a8pavqc9bblss5z9ikc9b0k0ra33vw73zy7rvn0v1wgvbqpc24k";
sha256 = "1zvjz2gv2vwqqjz52zcvi0ap3d8rdbpgsqk9wv80hqq4v37a5gfx";
};
};

Loading