forked from dan/liminix
1
0
Fork 0

test derivation for ci

This commit is contained in:
Daniel Barlow 2023-01-29 20:29:36 +00:00
parent 63bf4162b2
commit 3b1bc7eff8
2 changed files with 30 additions and 1 deletions

View File

@ -1,5 +1,5 @@
{
device ? (import devices/gl-ar750.nix)
device
, liminix-config ? <liminix-config>
, phram ? false
}:

29
tests/smoke/test.nix Normal file
View File

@ -0,0 +1,29 @@
{
liminix
, nixpkgs
}:
let img = (import liminix {
device = import "${liminix}/devices/qemu/";
liminix-config = ./configuration.nix;
}).outputs.squashfs;
pkgs = import <nixpkgs> {};
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; }