The majority of datacenters are within mixed-use facilities, where they often share some common infrastructures and energy supplies with other operations (e.g., non-IT offices and labs). In such mixed-use buildings, two major energy loads are datacenter IT equipment and HVAC (heating, ventilating, and air conditioning) system. The HVAC demand comes from both datacenter rooms and other non-IT rooms. To effectively lower peak demand and reduce energy cost for mixed-use buildings, it is important to leverage the scheduling flexibility from both the HVAC system and the delay-tolerant datacenter workload in a collaborative fashion. In this work, we model the major physical and cyber components of mixed-use buildings, and propose a model predictive control (MPC) formulation to co-schedule datacenter and HVAC loads, with consideration of solar energy and battery storage. The MPC formulation minimizes building energy cost while satisfying various requirements on room temperature, ventilation, and datacenter workload deadlines. Compared with separate scheduling strategy, our approach significantly reduces peak demand and overall energy cost, and provides better leverage of renewable energy supply. Furthermore, we demonstrate that our formulation is also effective in reducing carbon footprint, and balancing its trade-off with energy cost.