liminix/tests/smoke/test.nix

29 lines
905 B
Nix
Raw Normal View History

2023-01-29 21:29:36 +01:00
{
liminix
, nixpkgs
}:
let img = (import liminix {
device = import "${liminix}/devices/qemu/";
2023-02-05 23:38:21 +01:00
liminix-config = "${liminix}/vanilla-configuration.nix";
}).outputs.rootfs;
2023-01-29 21:29:36 +01:00
pkgs = import <nixpkgs> {};
2023-01-29 22:42:53 +01:00
in pkgs.runCommand "check" {
nativeBuildInputs = with pkgs; [ squashfsTools s6-rc ] ;
} ''
2023-01-29 21:29:36 +01:00
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
2023-01-29 22:42:53 +01:00
''