hocker-1.0.3: Interact with the docker registry and generate nix build instructions

Copyright(C) 2016 Awake Networks
LicenseApache-2.0
MaintainerAwake Networks <opensource@awakenetworks.com>
Stabilitystable
Safe HaskellNone
LanguageHaskell2010

Data.Docker.Nix.FetchDocker

Description

 

Synopsis

Documentation

constFetchdocker :: Text Source #

fetchdocker function name.

constFetchDockerConfig :: Text Source #

fetchDockerConfig function name.

constFetchDockerLayer :: Text Source #

fetchDockerLayer function name.

generate :: HockerImageMeta -> IO (Either HockerException NExpr) Source #

Generate a Nix expression AST from a HockerImageMeta record.

This function checks that the supplied manifest JSON contains a key in the top-level object describing what version of the manifest we have.

generateFetchDockerExpr :: HockerImageMeta -> ConfigDigest -> [(Base16Digest, Base32Digest)] -> Either HockerException NExpr Source #

Generate a top-level Nix Expression AST from a HockerImageMeta record, a config digest, and a list of layer digests.

The generated AST, pretty printed, may look similar to the following:

{ fetchdocker, fetchDockerConfig, fetchDockerLayer }:
fetchdocker rec {
  name = "debian";
  registry = "https://registry-1.docker.io/v2/";
  repository = "library";
  imageName = "debian";
  tag = "latest";
  imageConfig = fetchDockerConfig {
    inherit registry repository imageName tag;
    sha256 = "1viqbygsz9547jy830f2lk2hcrxjf7gl9h1xda9ws5kap8yw50ry";
  };
  imageLayers = let
    layer0 = fetchDockerLayer {
      inherit registry repository imageName;
      layerDigest = "10a267c67f423630f3afe5e04bbbc93d578861ddcc54283526222f3ad5e895b9";
      sha256 = "1fcmx3aklbr24qsjhm6cvmhqhmrxr6xlpq75mzrk0dj2gz36g8hh";
    };
    in [ layer0 ];
}

mkFetchDocker :: HockerImageMeta -> NExpr -> NExpr -> Either HockerException NExpr Source #

Generate a fetchdocker { ... } function call and argument attribute set. Please see generateFetchDockerExpr documentation for an example of full output.

mkFetchDockerConfig :: Binding NExpr -> Base32Digest -> NExpr Source #

Generate a fetchDockerConfig { ... } function call and argument attrset.

This function takes an argument for a list of static keys to inherit from the parent attribute set; it helps reduce the noise in the output expression.

mkFetchDockerLayers :: Binding NExpr -> [(Base16Digest, Base32Digest)] -> [Binding NExpr] Source #

Generate a list of Nix expression ASTs representing fetchDockerLayer { ... } function calls.

This function takes an argument for a list of static keys to inherit from the parent attribute set; it helps reduce the noise in the output expression.

NB: the hash digest tuple in the second argument is the base16 encoded hash digest plucked from the image's manifest JSON and a nix-hash base32 encoded copy.

This is necessary because fixed output derivations require a pre-computed hash (which we have, thanks to the manifest) and the hash must be base32 encoded using nix-hash's own base32 encoding. The base16 encoded hash digest is needed intact in order for the fetchDockerLayer builder script (which calls the hocker-layer utility) to download the layer from a docker registry.