fix broken perl build due to impurity and glibc-locales build with arbitrary nix store path

Perl build has an impurity (Issue #386), this fix resolves it. 

Also, if I build glibc-locales with non standard nix store location, the build is not successful due to a bug in locales.nix. This is a fix.