From b94174f4d353113de21998dad3050dd30a4291ec Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 26 Mar 2019 14:06:50 +0100 Subject: [PATCH] Add arion.build, arion.eval passthru functions --- arion.nix | 21 +++++++++++++++++++-- doc/manual/installation.asciidoc | 2 ++ tests/default.nix | 14 +++++++++++++- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/arion.nix b/arion.nix index 276cf0a..9a23bde 100644 --- a/arion.nix +++ b/arion.nix @@ -1,8 +1,9 @@ { stdenv, lib , coreutils, docker_compose, jq }: +let -stdenv.mkDerivation { + arion = stdenv.mkDerivation { name = "arion"; src = ./src; unpackPhase = ""; @@ -18,4 +19,20 @@ stdenv.mkDerivation { ; chmod a+x $out/bin/arion ''; -} + inherit passthru; + }; + + passthru = { + inherit eval build; + }; + + eval = import "${nix_dir}/eval-composition.nix"; + + build = args@{...}: + let composition = eval args; + in composition.config.build.dockerComposeYaml; + + nix_dir = "${arion.outPath}/share/arion/nix"; + +in + arion diff --git a/doc/manual/installation.asciidoc b/doc/manual/installation.asciidoc index 6f58112..4657d9a 100644 --- a/doc/manual/installation.asciidoc +++ b/doc/manual/installation.asciidoc @@ -17,6 +17,8 @@ nix-env -iA arion -f . TODO: describe: using nix-shell or in a script, building images as part of nix-build, pinning, see also todomvc-nix. +TODO: exposed Nix functions: arion.build, arion.eval (a bit of IFD) + == Mac or traditional Linux ``` diff --git a/tests/default.nix b/tests/default.nix index 27bbac2..cabdb61 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -1,8 +1,20 @@ { pkgs ? import ../pkgs.nix }: let - inherit (pkgs) nixosTest recurseIntoAttrs; + inherit (pkgs) nixosTest recurseIntoAttrs arion; in recurseIntoAttrs { + test = nixosTest ./arion-test; + + testBuild = arion.build { + + # To be more accurately, you can do + # pkgs = import ../examples/minimal/arion-pkgs.nix; + # but this is quite efficient: + inherit pkgs; + + modules = [ ../examples/minimal/arion-compose.nix ]; + }; + }