Do not build for commands that do not need images
This commit is contained in:
parent
0f6a1bd41f
commit
f503e556ea
2 changed files with 32 additions and 4 deletions
30
src/arion
30
src/arion
|
@ -136,6 +136,20 @@ for arg in "${args[@]}"; do
|
|||
echo "arg: $arg"
|
||||
done
|
||||
|
||||
do_eval() {
|
||||
echo 1>&2 "Evaluating configuration..."
|
||||
nix-instantiate \
|
||||
"$nix_dir/eval-docker-compose.nix" \
|
||||
--eval \
|
||||
--json \
|
||||
--argstr uid "$UID" \
|
||||
--arg modules "$modules" \
|
||||
--arg pkgs "$pkgs_argument" \
|
||||
--show-trace \
|
||||
--attr 'config.build.dockerComposeYamlText' \
|
||||
| jq -r . >$docker_compose_yaml;
|
||||
}
|
||||
|
||||
do_build() {
|
||||
echo 1>&2 "Building configuration..."
|
||||
nix-build \
|
||||
|
@ -191,7 +205,7 @@ do_repl_cleanup() {
|
|||
|
||||
case "$command" in
|
||||
cat)
|
||||
do_build
|
||||
do_eval
|
||||
jq . < "$docker_compose_yaml"
|
||||
;;
|
||||
repl)
|
||||
|
@ -201,8 +215,18 @@ case "$command" in
|
|||
if [[ ${#docker_compose_args[@]} != 0
|
||||
&& ${docker_compose_args[0]} != "help"
|
||||
&& ${docker_compose_args[0]} != "version"
|
||||
]]; then
|
||||
do_build
|
||||
]]; then
|
||||
case "${docker_compose_args[0]}" in
|
||||
help|version)
|
||||
:
|
||||
;;
|
||||
config|down|events|exec|images|kill|logs|pause|port|ps|rm|stop|top|unpause)
|
||||
do_eval
|
||||
;;
|
||||
*)
|
||||
do_build
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
docker-compose -f $docker_compose_yaml "${docker_compose_args[@]}"
|
||||
;;
|
||||
|
|
|
@ -30,6 +30,9 @@ in
|
|||
build.dockerComposeYaml = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
};
|
||||
build.dockerComposeYamlText = lib.mkOption {
|
||||
type = lib.types.string;
|
||||
};
|
||||
docker-compose.raw = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
};
|
||||
|
@ -39,7 +42,8 @@ in
|
|||
};
|
||||
};
|
||||
config = {
|
||||
build.dockerComposeYaml = pkgs.writeText "docker-compose.yaml" (builtins.toJSON (config.docker-compose.raw));
|
||||
build.dockerComposeYaml = pkgs.writeText "docker-compose.yaml" config.build.dockerComposeYamlText;
|
||||
build.dockerComposeYamlText = builtins.toJSON (config.docker-compose.raw);
|
||||
|
||||
docker-compose.raw = {
|
||||
version = "3";
|
||||
|
|
Loading…
Reference in a new issue