Use nix build inside of nixos test

Is it possible to successfully run nix build in an nixosTest? I’m getting No such file or directory errors in the build process.

I try to implement this for the test in this pr Init flake-auto-upgrade by StillerHarpo · Pull Request #229085 · NixOS/nixpkgs · GitHub

This is the derivation I came up with

      derivation {
        name = "attr1";
        builder = "${pkgs.bash}/bin/bash";
        args = [ ${
          pkgs.writeScript "attr1"
          "${pkgs.coreutils}/bin/mkdir $out; ${pkgs.coreutils}/bin/touch $out/result1"
        } ];