In the book "Combustion Theory" for Forman Williams, appendix A, and also in the book "Combustion Physics" for C.K. Law, chapter 1, the following derivation can be found for the chemical equilibrium criterion: $$\sum_{i} \mu_i dN_i = 0.$$ The derivation starts by stating out the first law of thermodynamics as: $$\delta Q = dE + \delta W = dE + pdV, \qquad (1)$$ where $\delta Q$ is the heat added to the system, $E$ is the internal energy and $\delta W = pdV$ is the work done by the system. Then, we state the second law of thermodynamics as: $$TdS \geq \delta Q, \qquad (2)$$ where $S$ is the entropy, and where the inequality holds for natural processes while equality holds for reversible processes. Combining equations (1) and (2) then gives $$dE \leq TdS - pdV, \qquad (3)$$ where again inequality holds for natural processes while equality holds for reversible processes.
Then, it is stated that for a single-component system, $S$ and $V$ suffice as independent variables to describe the state of the system, while for a multi-component system, we also need the mole numbers $N_i$ of the various species. In which case internal energy is written as: $$dE = TdS - pdV + \sum_i \mu_idN_i. \qquad (4)$$
Now, by comparing equations (3) and (4), we notice that $$\sum_{i} \mu_i dN_i \leq 0, \qquad (5)$$ where inequality holds for natural processes and equality holds at equilibrium. It is also stated in both books that this condition is general and not restricted to the conditions of constant temperature and constant pressure.
Well, the last step in this derivation just doesn't make any sense to me. My understanding is that in equations (1) and (3), it is implied that the system has a fixed composition ($dN_i = 0$), so you can't use them simultaneously with equation (4).
Also, I still recall the derivation of this equilibrium criterion in Callen's thermodynamics, where the author invoked the extremum principle at constant pressure and temperature, stated in terms of the Gibbs energy ($dG = 0$), from which he deduced the equality in equation (5). Thus, constant pressure and temperature are a requirement for the validity of the result.
So, am I missing something here, or is this derivation just as dumb as it looks?