nixos-config/lib/builders/build-docker-image.nix

37 lines
854 B
Nix
Raw Normal View History

2025-03-17 00:12:53 +00:00
{ dockerTools, lib, foodogsquaredLib }:
{ name, contents ? [ ], pathsToLink ? [ ], enableTypicalSetup ? true, ... }@attrs:
2025-03-17 00:12:53 +00:00
let
attrs' = lib.removeAttrs attrs [ "contents" "pathsToLink" "enableTypicalSetup" "name" ];
in
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
''}
2025-03-17 00:12:53 +00:00
${attrs.runAsRoot or ""}
'';
2025-03-17 00:12:53 +00:00
config = (attrs.config or {}) // lib.optionalAttrs enableTypicalSetup {
Cmd = [ "/bin/bash" ];
WorkingDir = "/data";
Volumes."/data" = { };
};
})