createDirs(): Handle ‘path’ being a symlink

In particular, this fixes "nix-build -o /tmp/result" on Mac OS X
(where /tmp is a symlink).
nix-env: Add regular expression support in selectors

So you can now do things like:

  $ nix-env -qa '.*zip.*'
  $ nix-env -qa '.*(firefox|chromium).*'
Don't recompile the same regex over and over