mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-04-16 06:19:11 +00:00
lib/builders: init custom Docker image builder
This commit is contained in:
parent
481edbf9b1
commit
cf597149bf
33
lib/builders/build-docker-image.nix
Normal file
33
lib/builders/build-docker-image.nix
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{ dockerTools, foodogsquaredLib }:
|
||||||
|
|
||||||
|
{ name, contents ? [ ], pathsToLink ? [ ], enableTypicalSetup ? true, ... }@attrs:
|
||||||
|
|
||||||
|
dockerTools.buildImage (attrs // {
|
||||||
|
name = "fds-${name}";
|
||||||
|
|
||||||
|
copyToRoot = foodogsquaredLib.buildFDSEnv {
|
||||||
|
inherit pathsToLink;
|
||||||
|
name = "fds-${name}-root";
|
||||||
|
paths =
|
||||||
|
contents
|
||||||
|
++ lib.optionals enableTypicalSetup (with dockerTools; [
|
||||||
|
usrBinEnv
|
||||||
|
binSh
|
||||||
|
caCertificates
|
||||||
|
fakeNss
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
|
||||||
|
runAsRoot = ''
|
||||||
|
${lib.optionalString enableTypicalSetup ''
|
||||||
|
mkdir -p /data
|
||||||
|
''}
|
||||||
|
${attrs.runAsRoot}
|
||||||
|
'';
|
||||||
|
|
||||||
|
config = attrs.config // lib.optionalAttrs enableTypicalSetup {
|
||||||
|
Cmd = [ "/bin/bash" ];
|
||||||
|
WorkingDir = "/data";
|
||||||
|
Volumes."/data" = { };
|
||||||
|
};
|
||||||
|
})
|
@ -224,4 +224,50 @@
|
|||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
buildDconfDb = pkgs.callPackage ./build-dconf-db.nix { };
|
buildDconfDb = pkgs.callPackage ./build-dconf-db.nix { };
|
||||||
|
|
||||||
|
/**
|
||||||
|
A wrapper for building Docker images.
|
||||||
|
|
||||||
|
# Arguments
|
||||||
|
|
||||||
|
A sole attribute set with the following attributes:
|
||||||
|
|
||||||
|
name
|
||||||
|
: Name of the container.
|
||||||
|
|
||||||
|
contents
|
||||||
|
: The contents of the FDS environment to be built with.
|
||||||
|
|
||||||
|
pathsToLink
|
||||||
|
: A list of directories to be shared with all of the derivations listed
|
||||||
|
from `contents`.
|
||||||
|
|
||||||
|
enableTypicalSetup
|
||||||
|
: Enable typical configuration.
|
||||||
|
|
||||||
|
The rest of the attributes are considered as part of the
|
||||||
|
`dockerTools.buildImage` argument.
|
||||||
|
|
||||||
|
# Type
|
||||||
|
|
||||||
|
```
|
||||||
|
buildDockerImage :: Attr -> Derivation
|
||||||
|
```
|
||||||
|
|
||||||
|
# Example
|
||||||
|
|
||||||
|
```nix
|
||||||
|
buildDockerImage {
|
||||||
|
name = "typical-webdev";
|
||||||
|
contents = with pkgs; [
|
||||||
|
hello
|
||||||
|
ruby
|
||||||
|
npm
|
||||||
|
pnpm
|
||||||
|
];
|
||||||
|
enableTypicalSetup = true;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
*/
|
||||||
|
buildDockerImage = pkgs.callPackage ./build-docker-image.nix { foodogsquaredLib = self; };
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ in pkgs.lib.makeExtensible (self:
|
|||||||
|
|
||||||
inherit (self.builders)
|
inherit (self.builders)
|
||||||
makeXDGMimeAssociationList makeXDGPortalConfiguration makeXDGDesktopEntry
|
makeXDGMimeAssociationList makeXDGPortalConfiguration makeXDGDesktopEntry
|
||||||
buildHugoSite buildFDSEnv buildDconfDb;
|
buildHugoSite buildFDSEnv buildDconfDb buildDockerImage;
|
||||||
inherit (self.trivial) countAttrs filterAttrs';
|
inherit (self.trivial) countAttrs filterAttrs';
|
||||||
inherit (self.data) importYAML renderTeraTemplate renderMustacheTemplate;
|
inherit (self.data) importYAML renderTeraTemplate renderMustacheTemplate;
|
||||||
inherit (self.fetchers) fetchInternetArchive fetchUgeeDriver;
|
inherit (self.fetchers) fetchInternetArchive fetchUgeeDriver;
|
||||||
|
Loading…
Reference in New Issue
Block a user