From 3b1bc7eff8037fd21f5a4f6298efad4557845633 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Sun, 29 Jan 2023 20:29:36 +0000 Subject: [PATCH] test derivation for ci --- default.nix | 2 +- tests/smoke/test.nix | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/smoke/test.nix diff --git a/default.nix b/default.nix index 281502f..8132bfe 100644 --- a/default.nix +++ b/default.nix @@ -1,5 +1,5 @@ { - device ? (import devices/gl-ar750.nix) + device , liminix-config ? , phram ? false }: diff --git a/tests/smoke/test.nix b/tests/smoke/test.nix new file mode 100644 index 0000000..ed1c57d --- /dev/null +++ b/tests/smoke/test.nix @@ -0,0 +1,29 @@ +{ + liminix +, nixpkgs +}: +let img = (import liminix { + device = import "${liminix}/devices/qemu/"; + liminix-config = ./configuration.nix; + }).outputs.squashfs; + pkgs = import {}; + check = pkgs.runCommand "check" { + nativeBuildInputs = with pkgs; [ squashfsTools s6-rc ] ; + } '' +destpath=$(mktemp -d)/smoke.img +echo $destpath +cleanup(){ test -n $destpath && test -d $destpath && chmod -R +w $destpath && rm -rf $destpath; } +trap cleanup EXIT +trap 'echo "command $(eval echo $BASH_COMMAND) failed with exit code $?"; exit $?' ERR +unsquashfs -q -d $destpath -excludes ${img} /dev +cd $destpath; +db=nix/store/*-s6-rc-database/compiled/ +test -d $db +chmod -R +w $db +# check we have closure of config.services (lo.link service exists only +# as a dependency) +test "$(s6-rc-db -c $db type lo.link)" = "oneshot" +test "$(s6-rc-db -c $db type ntp)" = "longrun" +echo OK > $out +''; +in { inherit check; }