In this paper, we present a Lagrangian variational formulation for nonequilibrium thermodynamics. This formulation is an extension of the Hamilton principle in classical mechanics that allows the inclusion of irreversible phenomena. The irreversibility is encoded into a nonlinear phenomenological constraint given by the expression of entropy production associated to all the irreversible processes involved. Hence from a mathematical point of view, our variational formulation may be regarded as a generalization of the Lagrange-d'Alembert principle used in nonlinear nonholonomic mechanics to the nonequilibrium thermodynamics, where the conventional Lagrange-d'Alembert principle cannot be applied since the nonlinear phenomenological constraint and its associated variational constraint must be separately treated. In our approach, to deal with the nonlinear nonholonomic constraint, we introduce a variable called the thermodynamic displacement associated to each irreversible process. This allows us systematically to define the corresponding variational constraint. In Part I, our variational theory is illustrated with various examples of discrete systems such as mechanical systems with friction, matter transfer, electric circuits, chemical reactions, and diffusion across membranes. In Part II of the present paper, we will extend our variational theory of discrete systems to the case of of continuum systems. Contents 1 Introduction 2 2 Some preliminaries 5 3 Variational formulation for nonequilibrium thermodynamics of simple systems 9 3.