Variational derivation of nuclear hydrodynamics