{ testers, ... }: testers.runNixOSTest ( { config, hostPkgs, ... }: let sources = import ../../../npins; pkgs = hostPkgs; dummyFile = hostPkgs.writeText "dummy" ""; tf = pkgs.callPackage ../../../launch/tf.nix { }; tfEnv = pkgs.callPackage ../../../launch/tf-env.nix { }; inherit (pkgs) lib; inherit (import ../../../panel/env.nix { inherit lib pkgs; }) BIN_PATH; tfVars = builtins.path { name = "basic.tfvars"; path = ./basic.tfvars; }; extraDependenciesFromMachine = machine: [ machine.system.build.toplevel.inputDerivation machine.system.build.etc.inputDerivation machine.system.build.etcBasedir.inputDerivation machine.system.build.etcMetadataImage.inputDerivation machine.system.build.extraUtils.inputDerivation machine.system.path.inputDerivation machine.system.build.setEnvironment.inputDerivation machine.system.build.vm.inputDerivation # machine.system.build.vmWithBootLoader.inputDerivation machine.system.build.bootStage1.inputDerivation machine.system.build.bootStage2.inputDerivation ] ++ lib.concatLists ( lib.mapAttrsToList ( _k: v: if v ? source.inputDerivation then [ v.source.inputDerivation ] else [ ] ) machine.environment.etc ); inherit (config) targetMachines pathToRoot pathFromRoot; in { name = "deployment-basic"; imports = [ (import ../common/nixosTest.nix { inherit config lib hostPkgs; }) ]; targetMachines = [ "hello" "cowsay" ]; pathToRoot = ../../..; pathFromRoot = "deployment/check/basic"; nodes = { deployer = { pkgs, nodes, ... }: { virtualisation = { memorySize = 32 * 1024; # FIXME: trim down - maybe make it an option diskSize = 50 * 1024; # FIXME: trim down - maybe make it an option cores = 8; # FIXME: trim down - maybe make it an option }; nix.settings = { substituters = lib.mkForce [ ]; hashed-mirrors = null; connect-timeout = 1; }; system.extraDependencies = lib.attrValues sources ++ [ pkgs.stdenv pkgs.stdenvNoCC # pkgs tfVars pkgs.bash pkgs.acl pkgs.attr pkgs.autoconf pkgs.automake pkgs.python3 pkgs.peertube pkgs.peertube.inputDerivation pkgs.gixy pkgs.gixy.inputDerivation ] ++ lib.concatLists ( map (tm: extraDependenciesFromMachine nodes.${tm}) (targetMachines ++ [ "fake" ]) ); environment.systemPackages = [ tf tfEnv ]; }; fake = { imports = [ ../basic/minimalTarget.nix ../../../services/fediversity ]; fediversity = { domain = "dummy"; garage.enable = true; mastodon = { enable = true; s3AccessKeyFile = dummyFile; s3SecretKeyFile = dummyFile; }; peertube = { enable = true; secretsFile = dummyFile; s3AccessKeyFile = dummyFile; s3SecretKeyFile = dummyFile; }; # pixelfed = { # enable = true; # s3AccessKeyFile = dummyFile; # s3SecretKeyFile = dummyFile; # }; temp.cores = 1; temp.initialUser = { username = "dummy"; displayName = "dummy"; email = "dummy"; passwordFile = dummyFile; }; }; }; } // lib.genAttrs targetMachines (_: { imports = [ ../basic/minimalTarget.nix ]; users.users.root.openssh.authorizedKeys.keyFiles = [ (pathToRoot + "/${pathFromRoot}/deployer.pub") ]; }); extraTestScript = '' with subtest("Check the status before deployment"): hello.fail("hello 1>&2") cowsay.fail("cowsay 1>&2") with subtest("Validate config"): deployer.wait_for_unit("multi-user.target") deployer.succeed("${lib.getExe tf} -chdir='${tfEnv}/launch' validate") with subtest("Run the deployment"): deployer.succeed("PATH=${BIN_PATH} ${lib.getExe tf} -chdir='${tfEnv}/launch' apply --auto-approve -lock=false -parallelism=1 -var-file='${tfVars}'") with subtest("Check the deployment"): hello.succeed("hello 1>&2") cowsay.succeed("cowsay hi 1>&2") ''; } )