{ 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; }; fakeMachine = pkgs.nixos [ ../basic/minimalTarget.nix ../../../launch/options.nix ../../../launch/shared.nix ../../../launch/garage.nix ../../../launch/mastodon.nix # prevent issue about multiple services on same nginx port: Segmentation fault (core dumped) gixy $out; This can be caused by combining multiple incompatible services on the same hostname. # ../../../launch/pixelfed.nix # ../../../launch/peertube.nix ../../../infra/test-machines/test01 { nix.nixPath = [ "/dummy/nix/path" ]; users.users.root.openssh.authorizedKeys.keys = [ "dummykey" ]; } { terraform = { domain = "fediversity.net"; hostname = "base"; initialUser = { displayName = "Testy McTestface"; username = "test"; email = "test@test.com"; password = "testtest"; }; }; } ]; 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 # The option `nodes.hello.virtualisation.vmVariantWithBootLoader._module.args.name' is defined multiple times while it's expected to be unique. machine.system.build.bootStage1.inputDerivation machine.system.build.bootStage2.inputDerivation machine.system.modulesTree.inputDerivation machine.system.build.binsh.inputDerivation machine.system.build.initialRamdisk.inputDerivation machine.system.build.initialRamdiskSecretAppender.inputDerivation machine.system.build.installBootLoader.inputDerivation machine.system.build.kernel.inputDerivation machine.system.build.nixos-enter.inputDerivation machine.system.build.nixos-generate-config.inputDerivation machine.system.build.nixos-install.inputDerivation machine.system.build.nixos-option.inputDerivation machine.system.build.nixos-rebuild.inputDerivation machine.system.build.separateActivationScript.inputDerivation machine.system.build.uki.inputDerivation # machine.system.outPath ] ++ machine.environment.systemPackages ++ 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 = [ (pkgs.closureInfo { rootPaths = ( lib.attrValues sources ++ [ pkgs.stdenv pkgs.stdenvNoCC # pkgs tf tf.inputDerivation tfEnv tfEnv.inputDerivation 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.python3Packages.mdit-py-plugins pkgs.python3Packages.mdit-py-plugins.inputDerivation pkgs.python3Packages.markdown-it-py pkgs.python3Packages.markdown-it-py.inputDerivation pkgs.peertube pkgs.peertube.inputDerivation pkgs.gixy pkgs.gixy.inputDerivation pkgs.postgresql_15 pkgs.mtools pkgs.mtools.inputDerivation pkgs.lkl pkgs.lkl.inputDerivation pkgs.nftables pkgs.nftables.inputDerivation pkgs.musl pkgs.musl.inputDerivation pkgs.w3m # why in the world?! pkgs.w3m.inputDerivation pkgs.byacc pkgs.byacc.inputDerivation pkgs.openssh pkgs.openssh.inputDerivation pkgs.curl pkgs.curl.inputDerivation pkgs.coreutils pkgs.coreutils.inputDerivation pkgs.krb5 pkgs.krb5.inputDerivation pkgs.libssh2 pkgs.libssh2.inputDerivation pkgs.nghttp2 pkgs.nghttp2.inputDerivation pkgs.openssl pkgs.openssl.inputDerivation ] ++ lib.concatLists ( map extraDependenciesFromMachine (map (tm: nodes.${tm}) targetMachines ++ [ fakeMachine.config ]) ) ); }) ]; environment.systemPackages = [ tf tfEnv ]; }; } // 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}' >&2") with subtest("Check the deployment"): hello.succeed("hello 1>&2") cowsay.succeed("cowsay hi 1>&2") ''; } )