I did the Dark Brotherhood quest where you kill Nilsine Shatter-Shield and Alain Dufont, so since Nilsine is dead, I can't do Blood on the Ice. Do I need to do that quest to buy a house, or can I just do the Falkreath liberation quest?
According to UESP’s article on Hjerim, you don’t need to complete Blood on the Ice before purchasing the house. Just proceed with the civil war until the Jarl of Windhelm offers you a chance to purchase the house.
However, you should still be able to complete Blood on the Ice after killing Nilsine. From UESP’s article on Blood on the Ice:
If you've killed Nilsine in order to get a bonus reward in the quest Mourning Never Comes, Tova will be dead inside her house, and you will need to pick the lock of her house in order to get the key to Hjerim.
UESP also says that if you don’t start Blood on the Ice before purchasing Hjerim, the quest will start the first time you enter the house.