{ pkgs ? import sources.nixpkgs { overlays = [ (import ./pkgs { }) ]; } , sources ? import ./nix/sources.nix }: let haskellPackages = pkgs.haskell.packages.ghc98; makeDocTest = n: i: (import (sources.nixpkgs + "/nixos/lib") { }).runTest { name = "doc-test-${n}"; imports = [{ nodes = { machine = { lib, pkgs, nodes, ... }: { environment.systemPackages = [ ]; systemd.services.backend.wantedBy = [ "multi-user.target" ]; systemd.services.backend.preStart = '' export HOME=$(mktemp -d) ${pkgs.git}/bin/git config --global user.email "you@example.com" ${pkgs.git}/bin/git config --global user.name "Your Name" ${pkgs.git}/bin/git init ${pkgs.git}/bin/git commit -m init --allow-empty ''; systemd.services.backend.script = '' UUID_SEED=0 ${haskellPackages.backend}/bin/backend serve . ''; }; }; testScript = '' start_all(); machine.wait_for_unit("backend"); machine.succeed("${pkgs.bash}/bin/bash ${makeDocTestScript n i}"); ''; }]; hostPkgs = pkgs; defaults.networking.firewall.enable = false; }; makeDocTestScript = n: i: pkgs.runCommand "doc-test-script-${n}" { } '' set -efu export PATH=${pkgs.lib.makeBinPath [ pkgs.coreutils pkgs.glow pkgs.jq pkgs.pandoc ]} ( cat <<'EOF' set -efux readonly tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT cd "$tmp" export ACMS_CONTENT=$PWD/content # TODO export PATH=${pkgs.lib.makeBinPath [ haskellPackages.cli pkgs.jq ]}''${PATH+:$PATH} EOF cat ${i} | pandoc --to json | jq -c ' .blocks | map(select(.t == "CodeBlock") | .c | { t: .[0].[1].[0], v: .[1] } ) | .[] ' | while read -r l; do t=$(echo "$l" | jq -r .t) v=$(echo "$l" | jq -r .v) if test "$t" = console; then cat < $out ''; in { api-reference = makeDocTest "api-reference" ./docs/api-reference.md; get-started-cli = makeDocTest "get-started-cli" ./docs/get-started-cli.md; }