Capacitive mixing (CapMix) and capacitive deionization (CDI) are currently developed as alternatives to membrane-based processes to harvest blue energy-from salinity gradients between river and sea waterand to desalinate water-using charge-discharge cycles of capacitors. Nanoporous electrodes increase the contact area with the electrolyte and hence, in principle, also the performance of the process. However, models to design and optimize devices should be used with caution when the size of the pores becomes comparable to that of ions and water molecules. Here, we address this issue by simulating realistic capacitors based on aqueous electrolytes and nanoporous carbide-derived carbon (CDC) electrodes, accounting for both their complex structure and their polarization by the electrolyte under applied voltage. We compute the capacitance for two salt concentrations and validate our simulations by comparison with cyclic voltammetry experiments. We discuss the predictions of Debye-Hückel and Poisson-Boltzmann theories, as well as modified Donnan models, and we show that the latter can be parametrized using the molecular simulation results at high concentration. This then allows us to extrapolate the capacitance and salt adsorption capacity at lower concentrations, which cannot be simulated, finding a reasonable agreement with the experimental capacitance. We analyze the solvation of ions and their confinement within the electrodes-microscopic properties that are much more difficult to obtain experimentally than the electrochemical response but very important to understand the mechanisms at play. We finally discuss the implications of our findings for CapMix and CDI, both from the modeling point of view and from the use of CDCs in these contexts.