Concretely, you would need to keep track of and reproduce e.g. the march flag value as a part of your build input. If you wanted to optimize for multiple architectures, that would mean separate builds or a larger binary with function multi-versioning.
If you want to compile any piece of software available in Nixpkgs, you can override it's attributes (inputs used to build it).
One can trivially have an almost identical operation system to your colleagues install, but override just one package to enable optimisations for a certain cpu. This would however imply that you'd lose the transparent binary cache that you could otherwise use.
Exactly this method is used to configure the entire operating install! Your OS install is just another package that has some custom inputs set.