All Praise be to Allaah.
Some powders and cosmetics that are used as makeup form a insulating layer over the skin and prevent water from reaching it, while others do not prevent water from reaching the skin.
If a cosmetic item insulates the skin (e.g., nailpolish as asked in the question) then it is not permissible to perform wudoo' or ghusl over it, for any act of worship that requires wudoo or ghusl (such as prayer, etc.). Allaah the most glorified and Almighty says (interpretation of the meaning):
"O you who believe! When you prepare for prayer, wash your faces and hands …." Al-Maa'idah (5:6)
Washing implies that water must actually reach the part of the body being washed. Based on this observation, anything that prevents water from reaching the skin must be removed, otherwise purification will not be achieved, resulting in the prayer being void.
If the cosmetic item does not insulate the skin and does not prevent water from reaching it (e.g., dying by henna or similar things which do not insulate the skin), then wudoo' or ghusl may be performed with it.
Hence, dyes are of two type: the first is that which is waterproof, such as nailpolish, which must be removed before performing wudoo' or ghusl. The second is that which does not form an impermeable barrier to water, such as henna dye, and hence does not hurt the wudoo or ghusl.
And Allah the most glorified and Almighty knows what is most correct and best.
Al-Mufassal fi Ahkaam Al-Mar’ah, Abdul Karim Zaidan, 1/84-85.
Fataawi Al-Mar’ah Al-Muslimah, Shaykh Muhammad bin Salih Al-Uthaymeen, 1/220.
Ahkaam Tajmeel Al-Nisaa’ fi Al-Shari‘ah Al-Islamiyyah, Izdihar Al-Madani.
Zeenat Al-Mar’ah bayn Al-Tibb wa Al-Shar‘
Sheikh Muhammed Salih Al-Munajjid