mirror of
https://github.com/hercules-ci/arion.git
synced 2024-11-29 22:51:11 +03:00
commit
da7091c37b
20
arion.nix
Normal file
20
arion.nix
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{ stdenv, lib
|
||||||
|
, coreutils, docker_compose, jq
|
||||||
|
}:
|
||||||
|
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
name = "arion";
|
||||||
|
src = ./src;
|
||||||
|
unpackPhase = "";
|
||||||
|
buildPhase = "";
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/bin $out/share/arion
|
||||||
|
cp -a nix $out/share/arion/
|
||||||
|
cp -a arion-image $out/share/arion/
|
||||||
|
substitute arion $out/bin/arion \
|
||||||
|
--subst-var-by path ${lib.makeBinPath [jq coreutils docker_compose]} \
|
||||||
|
--subst-var-by nix_dir $out/share/arion/nix \
|
||||||
|
;
|
||||||
|
chmod a+x $out/bin/arion
|
||||||
|
'';
|
||||||
|
}
|
26
default.nix
26
default.nix
@ -1,26 +1,6 @@
|
|||||||
{ pkgs ? import <nixpkgs> {} }:
|
{ pkgs ? import ./pkgs.nix }:
|
||||||
|
|
||||||
let
|
|
||||||
inherit (pkgs) lib stdenv;
|
|
||||||
|
|
||||||
arion = stdenv.mkDerivation {
|
|
||||||
name = "arion";
|
|
||||||
src = ./src;
|
|
||||||
unpackPhase = "";
|
|
||||||
buildPhase = "";
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p $out/bin $out/share/arion
|
|
||||||
cp -a nix $out/share/arion/
|
|
||||||
cp -a arion-image $out/share/arion/
|
|
||||||
substitute arion $out/bin/arion \
|
|
||||||
--subst-var-by path ${lib.makeBinPath [pkgs.jq pkgs.coreutils]} \
|
|
||||||
--subst-var-by nix_dir $out/share/arion/nix \
|
|
||||||
;
|
|
||||||
chmod a+x $out/bin/arion
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
inherit arion;
|
inherit (pkgs) arion;
|
||||||
|
tests = pkgs.callPackage ./tests {};
|
||||||
}
|
}
|
||||||
|
3
pkgs.nix
Normal file
3
pkgs.nix
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import <nixpkgs> {
|
||||||
|
overlays = [ (self: super: { arion = super.callPackage ./arion.nix {}; }) ];
|
||||||
|
}
|
34
tests/arion-test/default.nix
Normal file
34
tests/arion-test/default.nix
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
# To make some prebuilt derivations available in the vm
|
||||||
|
preEval = import ../../src/nix/eval-docker-compose.nix {
|
||||||
|
modules = [ ../../examples/minimal/arion-compose.nix ];
|
||||||
|
inherit pkgs;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
name = "arion-test";
|
||||||
|
machine = { pkgs, lib, ... }: {
|
||||||
|
environment.systemPackages = [
|
||||||
|
pkgs.arion
|
||||||
|
pkgs.docker-compose
|
||||||
|
];
|
||||||
|
virtualisation.docker.enable = true;
|
||||||
|
|
||||||
|
# no caches, because no internet
|
||||||
|
nix.binaryCaches = lib.mkForce [];
|
||||||
|
virtualisation.writableStore = true;
|
||||||
|
virtualisation.pathsInNixDB = [
|
||||||
|
# Pre-build the image because we don't want to build the world
|
||||||
|
# in the vm.
|
||||||
|
preEval.config.build.dockerComposeYaml
|
||||||
|
];
|
||||||
|
};
|
||||||
|
testScript = ''
|
||||||
|
$machine->fail("curl localhost:8000");
|
||||||
|
$machine->succeed("docker --version");
|
||||||
|
$machine->succeed("cp -r ${../../examples/minimal} work && cd work && NIX_PATH=nixpkgs='${pkgs.path}' arion up -d");
|
||||||
|
$machine->waitUntilSucceeds("curl localhost:8000");
|
||||||
|
'';
|
||||||
|
}
|
8
tests/default.nix
Normal file
8
tests/default.nix
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{ pkgs ? import ../pkgs.nix }:
|
||||||
|
let
|
||||||
|
inherit (pkgs) nixosTest recurseIntoAttrs;
|
||||||
|
in
|
||||||
|
|
||||||
|
recurseIntoAttrs {
|
||||||
|
test = nixosTest ./arion-test;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user