We present the linear-response matrix for a sliding domain wall in a rotatable magnetic nanowire, which is driven out of equilibrium by temperature and voltage bias, mechanical torque, and magnetic field. An expression for heat-current-induced domain-wall motion is derived. Application of Onsager's reciprocity relation leads to a unified description of the Barnett and Einstein-de Haas effects as well as spin-dependent thermoelectric properties. We envisage various heat pumps and engines, such as coolers driven by magnetic fields or mechanical rotation as well as nanoscale motors that convert temperature gradients into useful work. All parameters ͑with the exception of mechanical friction͒ can be computed microscopically by the scattering theory of transport.