diff --git a/examples/custom-image/arion-compose.nix b/examples/custom-image/arion-compose.nix new file mode 100644 index 0000000..0436eaf --- /dev/null +++ b/examples/custom-image/arion-compose.nix @@ -0,0 +1,33 @@ +{ pkgs, ... }: + +let + webRoot = "/www"; + + webserverImage = pkgs.dockerTools.buildLayeredImage { + name = "a-webserver"; + + config = { + Entrypoint = [ + "${pkgs.darkhttpd}/bin/darkhttpd" webRoot + ]; + + Volumes = { + "${webRoot}" = {}; + }; + }; + }; +in { + config.services = { + + webserver = { + image.drv = webserverImage; + service.command = [ "--port" "8000" ]; + service.ports = [ + "8000:8000" # host:container + ]; + service.volumes = [ + "${webRoot}:${pkgs.nix.doc}/share/doc/nix/manual" + ]; + }; + }; +} diff --git a/examples/custom-image/arion-pkgs.nix b/examples/custom-image/arion-pkgs.nix new file mode 100644 index 0000000..69aad13 --- /dev/null +++ b/examples/custom-image/arion-pkgs.nix @@ -0,0 +1,6 @@ +# Instead of pinning Nixpkgs, we can opt to use the one in NIX_PATH +import { + # We specify the architecture explicitly. Use a Linux remote builder when + # calling arion from other platforms. + system = "x86_64-linux"; +} diff --git a/tests/arion-test/default.nix b/tests/arion-test/default.nix index 5bea4fe..7d26e9c 100644 --- a/tests/arion-test/default.nix +++ b/tests/arion-test/default.nix @@ -31,6 +31,7 @@ in # Pre-build the image because we don't want to build the world # in the vm. (preEval [ ../../examples/minimal/arion-compose.nix ]).config.out.dockerComposeYaml + (preEval [ ../../examples/custom-image/arion-compose.nix ]).config.out.dockerComposeYaml (preEval [ ../../examples/full-nixos/arion-compose.nix ]).config.out.dockerComposeYaml (preEval [ ../../examples/nixos-unit/arion-compose.nix ]).config.out.dockerComposeYaml pkgs.stdenv @@ -53,6 +54,7 @@ in }; $makeSubtest->("minimal", "${../../examples/minimal}"); + $makeSubtest->("custom-image", "${../../examples/custom-image}"); $makeSubtest->("full-nixos", "${../../examples/full-nixos}", sub { $machine->succeed("cd work && export NIX_PATH=nixpkgs='${pkgs.path}' && (echo 'nix run -f ~/h/arion arion -c arion exec webserver'; echo 'target=world; echo Hello \$target'; echo exit) | script /dev/null | grep 'Hello world'"); });