  In this paper we introduce a generalization of the Nakayama functor for
finite-dimensional algebras. This is obtained by abstracting its interaction
with the forgetful functor to vector spaces. In particular, we characterize the
Nakayama functor in terms of an ambidextrous adjunction of monads and comonads.
In the second part we develop a theory of Gorenstein homological algebra for
such Nakayama functor. We obtain analogues of several classical results for
Iwanaga-Gorenstein algebras. One of our main examples is the module category
$\Lambda\text{-}\operatorname{Mod}$ of a $k$-algebra $\Lambda$, where $k$ is a
commutative ring and $\Lambda$ is finitely generated projective as a
$k$-module.
