{ 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.bash.inputDerivation pkgs.acl pkgs.acl.inputDerivation pkgs.attr pkgs.attr.inputDerivation pkgs.autoconf pkgs.autoconf.inputDerivation pkgs.automake pkgs.automake.inputDerivation pkgs.python3 pkgs.python3.inputDerivation pkgs.peertube pkgs.peertube.inputDerivation pkgs.gixy pkgs.gixy.inputDerivation pkgs.postgresql_15 ] ++ lib.concatLists ( map (tm: extraDependenciesFromMachine nodes.${tm}) (targetMachines ++ [ "fake" ]) ); environment.systemPackages = [ tf tfEnv ]; }; fake = { imports = [ ../basic/minimalTarget.nix ## NOTE: Cannot use ../../../launch/shared.nix because it involves ## and . ( { pkgs, ... }: let hostname = "dummy"; domain = "dummy"; initialUser = { username = "dummy"; email = "dummy"; displayName = "dummy"; }; in { imports = [ # # ../../../services/fediversity ../../../launch/resource.nix ]; fediversityVm.name = hostname; fediversity = { inherit domain; temp.initialUser = { inherit (initialUser) username email displayName; # FIXME: disgusting, but nvm, this is going to be replaced by # proper central authentication at some point passwordFile = pkgs.writeText "password" initialUser.password; }; }; } ) ../../../launch/garage.nix ../../../launch/mastodon.nix ../../../launch/pixelfed.nix ../../../launch/peertube.nix ]; }; } // 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") ''; } )