2019-01-02 09:54:46 +01:00
{ pkgs , . . . }:
let
# To make some prebuilt derivations available in the vm
2019-03-05 19:41:54 +01:00
preEval = modules : import ../../src/nix/eval-composition.nix {
inherit modules ;
2019-01-02 09:54:46 +01:00
inherit pkgs ;
} ;
in
{
name = " a r i o n - t e s t " ;
machine = { pkgs , lib , . . . }: {
environment . systemPackages = [
pkgs . arion
] ;
virtualisation . docker . enable = true ;
# no caches, because no internet
nix . binaryCaches = lib . mkForce [ ] ;
2019-01-27 01:08:51 +01:00
# FIXME: Sandbox seems broken with current version of NixOS test
# w/ writable store. Error:
# machine# error: linking '/nix/store/7r8z2zvhwda85pgpdn5hzzz6hs1njklc-stdenv-linux.drv.chroot/nix/store/6v3y7s4q4wd16hsw393gjpxvcf9159bv-patch-shebangs.sh' to '/nix/store/6v3y7s4q4wd16hsw393gjpxvcf9159bv-patch-shebangs.sh': Operation not permitted
#
# There should be no reason why arion can't run without
# sandboxing, so please re-enable.
nix . useSandbox = false ;
2019-01-02 09:54:46 +01:00
virtualisation . writableStore = true ;
virtualisation . pathsInNixDB = [
# Pre-build the image because we don't want to build the world
# in the vm.
2019-03-05 19:41:54 +01:00
( preEval [ ../../examples/minimal/arion-compose.nix ] ) . config . build . dockerComposeYaml
( preEval [ ../../examples/full-nixos/arion-compose.nix ] ) . config . build . dockerComposeYaml
( preEval [ ../../examples/nixos-unit/arion-compose.nix ] ) . config . build . dockerComposeYaml
2019-01-27 01:08:51 +01:00
pkgs . stdenv
2019-01-02 09:54:46 +01:00
] ;
} ;
testScript = ''
$ machine- > fail ( " c u r l l o c a l h o s t : 8 0 0 0 " ) ;
$ machine- > succeed ( " d o c k e r - - v e r s i o n " ) ;
2019-03-05 19:41:54 +01:00
subtest " m i n i m a l " , sub {
$ machine- > succeed ( " c p - r ${ ../../examples/minimal } w o r k & & c d w o r k & & N I X _ P A T H = n i x p k g s = ' ${ pkgs . path } ' a r i o n u p - d " ) ;
$ machine- > waitUntilSucceeds ( " c u r l l o c a l h o s t : 8 0 0 0 " ) ;
$ machine- > succeed ( " c d w o r k & & N I X _ P A T H = n i x p k g s = ' ${ pkgs . path } ' a r i o n d o w n & & r m - r f w o r k " ) ;
$ machine- > waitUntilFails ( " c u r l l o c a l h o s t : 8 0 0 0 " ) ;
} ;
subtest " f u l l - n i x o s " , sub {
$ machine- > succeed ( " c p - r ${ ../../examples/full-nixos } w o r k & & c d w o r k & & N I X _ P A T H = n i x p k g s = ' ${ pkgs . path } ' a r i o n u p - d " ) ;
$ machine- > waitUntilSucceeds ( " c u r l l o c a l h o s t : 8 0 0 0 " ) ;
2019-03-21 15:10:21 +01:00
# Also test exec with defaultExec
$ machine- > succeed ( " c d w o r k & & e x p o r t N I X _ P A T H = n i x p k g s = ' ${ pkgs . path } ' & & ( e c h o ' n i x r u n - f ~ / h / a r i o n a r i o n - c a r i o n e x e c w e b s e r v e r ' ; e c h o ' t a r g e t = w o r l d ; e c h o H e l l o \$ t a r g e t ' ; e c h o e x i t ) | s c r i p t / d e v / n u l l | g r e p ' H e l l o w o r l d ' " ) ;
2019-03-05 19:41:54 +01:00
$ machine- > succeed ( " c d w o r k & & N I X _ P A T H = n i x p k g s = ' ${ pkgs . path } ' a r i o n d o w n & & r m - r f w o r k " ) ;
$ machine- > waitUntilFails ( " c u r l l o c a l h o s t : 8 0 0 0 " ) ;
} ;
subtest " n i x o s - u n i t " , sub {
$ machine- > succeed ( " c p - r ${ ../../examples/nixos-unit } w o r k & & c d w o r k & & N I X _ P A T H = n i x p k g s = ' ${ pkgs . path } ' a r i o n u p - d " ) ;
$ machine- > waitUntilSucceeds ( " c u r l l o c a l h o s t : 8 0 0 0 " ) ;
$ machine- > succeed ( " c d w o r k & & N I X _ P A T H = n i x p k g s = ' ${ pkgs . path } ' a r i o n d o w n & & r m - r f w o r k " ) ;
$ machine- > waitUntilFails ( " c u r l l o c a l h o s t : 8 0 0 0 " ) ;
} ;
2019-01-02 09:54:46 +01:00
'' ;
}