This commits mitigates https://github.com/NixOS/nixpkgs/issues/10026. Thanks to @namore for contributing most of the update!