liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

test.nix (1270B)


      1 let
      2   img =
      3     (import <liminix> {
      4       device = import <liminix/devices/qemu>;
      5       liminix-config = { ... }:
      6         {
      7           imports = [ <liminix/vanilla-configuration.nix> ];
      8           config.hosts = {
      9             "127.0.0.53" = [ "apple" "orange" ];
     10           };
     11         };
     12     }).outputs.rootfs;
     13   pkgs = import <nixpkgs> { };
     14 in
     15 pkgs.runCommand "check"
     16   {
     17     nativeBuildInputs = with pkgs; [
     18       squashfsTools
     19       s6-rc
     20     ];
     21   }
     22   ''
     23     destpath=$(mktemp -d)/smoke.img
     24     echo $destpath
     25     cleanup(){  test -n $destpath && test -d $destpath && chmod -R +w $destpath && rm -rf $destpath;  }
     26     trap cleanup EXIT
     27     trap 'echo "command $(eval echo $BASH_COMMAND) failed with exit code $?"; exit $?' ERR
     28     unsquashfs -q -d $destpath -excludes ${img}  /dev
     29     cd $destpath;
     30     hostsfile=$(echo $(readlink etc/hosts) | sed 's/^.//')
     31     grep -q -E '127.0.0.1.+localhost' $hostsfile
     32     grep -q -E '127.0.0.53.+apple.+orange' $hostsfile
     33     db=nix/store/*-s6-rc-database/compiled/
     34     test -d $db
     35     chmod -R +w $db
     36     # check we have closure of config.services (lo.link service exists only
     37     # as a dependency)
     38     test "$(s6-rc-db -c $db type lo.link)" = "oneshot"
     39     test "$(s6-rc-db -c $db type ntp)" = "longrun"
     40     echo OK > $out
     41   ''