Possibly
"Little Nemo: Adventures in Slumberland" (1989) It's about a little boy named Nemo who has a problem keeping his promises. In his sleep he travels to slumberland and is befriended by King Morpheus. The Princess fancies Nemo and makes him her playmate. King Morpheus gives Nemo a key that can open any door and makes him promise not to open the door with the same symbol as is on the key. Nemo promises but influenced by Flip (voiced by Mickey Rooney) The no-good clown, he opens the forbidden door and unleashes the Nightmare (which is the part with the castle and the goo) When the nightmare is unleashed a black goo fills the palace during Nemo's coronation as Prince of Slumberland and kidnaps the king. As Nemo was the only one in possession of the key he is blamed for the loss of the king and embarks on a journey to Nightmareland with the princess the kings adviser and Flip who has the one and only map of Nightmareland. Together they rescue King Morpheus and destroy the nightmare king forever.
Hope that helped! If not sorry
Edit: I know the name isn't the same, but Nemo starts with an N same as NIMH and Slumberland starts with an S same as Secret so it may be your answer

and The Secret of NIMH has a scene where Mrs. Brisby's house (a cinderblock) is sinking into a mud puddle and filling with mud while her children are still inside so you were on the right track.