mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
dockerTools: add includeNixDB to buildImage and document
This commit is contained in:
parent
c055845069
commit
62e9e0f963
@ -185,6 +185,19 @@ Similarly, if you encounter errors similar to `Error_Protocol ("certificate has
|
|||||||
_Default value:_ `"gz"`.\
|
_Default value:_ `"gz"`.\
|
||||||
_Possible values:_ `"none"`, `"gz"`, `"zstd"`.
|
_Possible values:_ `"none"`, `"gz"`, `"zstd"`.
|
||||||
|
|
||||||
|
`includeNixDB` (Boolean; _optional_)
|
||||||
|
|
||||||
|
: Populate the nix database in the image with the dependencies of `copyToRoot`.
|
||||||
|
The main purpose is to be able to use nix commands in the container.
|
||||||
|
|
||||||
|
:::{.caution}
|
||||||
|
Be careful since this doesn't work well in combination with `fromImage`. In particular, in a multi-layered image, only the Nix paths from the lower image will be in the database.
|
||||||
|
|
||||||
|
This also neglects to register the store paths that are pulled into the image as a dependency of one of the other values, but aren't a dependency of `copyToRoot`.
|
||||||
|
:::
|
||||||
|
|
||||||
|
_Default value:_ `false`.
|
||||||
|
|
||||||
`contents` **DEPRECATED**
|
`contents` **DEPRECATED**
|
||||||
|
|
||||||
: This attribute is deprecated, and users are encouraged to use `copyToRoot` instead.
|
: This attribute is deprecated, and users are encouraged to use `copyToRoot` instead.
|
||||||
|
@ -570,6 +570,8 @@ rec {
|
|||||||
created ? "1970-01-01T00:00:01Z"
|
created ? "1970-01-01T00:00:01Z"
|
||||||
, # Compressor to use. One of: none, gz, zstd.
|
, # Compressor to use. One of: none, gz, zstd.
|
||||||
compressor ? "gz"
|
compressor ? "gz"
|
||||||
|
# Populate the nix database in the image with the dependencies of `copyToRoot`.
|
||||||
|
, includeNixDB ? false
|
||||||
, # Deprecated.
|
, # Deprecated.
|
||||||
contents ? null
|
contents ? null
|
||||||
,
|
,
|
||||||
@ -607,20 +609,26 @@ rec {
|
|||||||
|
|
||||||
compress = compressorForImage compressor name;
|
compress = compressorForImage compressor name;
|
||||||
|
|
||||||
|
# TODO: add the dependencies of the config json.
|
||||||
|
extraCommandsWithDB =
|
||||||
|
if includeNixDB then (mkDbExtraCommand rootContents) + extraCommands
|
||||||
|
else extraCommands;
|
||||||
|
|
||||||
layer =
|
layer =
|
||||||
if runAsRoot == null
|
if runAsRoot == null
|
||||||
then
|
then
|
||||||
mkPureLayer
|
mkPureLayer
|
||||||
{
|
{
|
||||||
name = baseName;
|
name = baseName;
|
||||||
inherit baseJson keepContentsDirlinks extraCommands uid gid;
|
inherit baseJson keepContentsDirlinks uid gid;
|
||||||
|
extraCommands = extraCommandsWithDB;
|
||||||
copyToRoot = rootContents;
|
copyToRoot = rootContents;
|
||||||
} else
|
} else
|
||||||
mkRootLayer {
|
mkRootLayer {
|
||||||
name = baseName;
|
name = baseName;
|
||||||
inherit baseJson fromImage fromImageName fromImageTag
|
inherit baseJson fromImage fromImageName fromImageTag
|
||||||
keepContentsDirlinks runAsRoot diskSize buildVMMemorySize
|
keepContentsDirlinks runAsRoot diskSize buildVMMemorySize;
|
||||||
extraCommands;
|
extraCommands = extraCommandsWithDB;
|
||||||
copyToRoot = rootContents;
|
copyToRoot = rootContents;
|
||||||
};
|
};
|
||||||
result = runCommand "docker-image-${baseName}.tar${compress.ext}"
|
result = runCommand "docker-image-${baseName}.tar${compress.ext}"
|
||||||
@ -879,18 +887,9 @@ rec {
|
|||||||
# the container.
|
# the container.
|
||||||
# Be careful since this doesn't work well with multilayer.
|
# Be careful since this doesn't work well with multilayer.
|
||||||
# TODO: add the dependencies of the config json.
|
# TODO: add the dependencies of the config json.
|
||||||
buildImageWithNixDb = args@{ copyToRoot ? contents, contents ? null, extraCommands ? "", ... }: (
|
buildImageWithNixDb = args: buildImage (args // { includeNixDB = true; });
|
||||||
buildImage (args // {
|
|
||||||
extraCommands = (mkDbExtraCommand copyToRoot) + extraCommands;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
# TODO: add the dependencies of the config json.
|
buildLayeredImageWithNixDb = args: buildLayeredImage (args // { includeNixDB = true; });
|
||||||
buildLayeredImageWithNixDb = args@{ contents ? null, extraCommands ? "", ... }: (
|
|
||||||
buildLayeredImage (args // {
|
|
||||||
extraCommands = (mkDbExtraCommand contents) + extraCommands;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
# Arguments are documented in ../../../doc/build-helpers/images/dockertools.section.md
|
# Arguments are documented in ../../../doc/build-helpers/images/dockertools.section.md
|
||||||
streamLayeredImage = lib.makeOverridable (
|
streamLayeredImage = lib.makeOverridable (
|
||||||
@ -911,7 +910,6 @@ rec {
|
|||||||
, fakeRootCommands ? ""
|
, fakeRootCommands ? ""
|
||||||
, enableFakechroot ? false
|
, enableFakechroot ? false
|
||||||
, includeStorePaths ? true
|
, includeStorePaths ? true
|
||||||
# Generate a Nix DB inside the image. The same caveats as `buildImageWithNixDb` apply.
|
|
||||||
, includeNixDB ? false
|
, includeNixDB ? false
|
||||||
, passthru ? {}
|
, passthru ? {}
|
||||||
,
|
,
|
||||||
|
Loading…
Reference in New Issue
Block a user