Nix build too large docker image

Hi,

I just started trying to build a docker image with nix. And I read this blog Thoughts about computer technologies: Cheap Docker images with Nix. That says the redis docker image nix builds is about 25 mb in size. Then I tried to build this redis docker image on a my mac but the final size of the image is about 177mb, it’s too large. I also try to build the same redis image on a ubuntu server, and the size of the image is still 177mb.

Here is my redis.nix :

with import <nixpkgs> {};

dockerTools.buildImage {
  name = "redis";
  runAsRoot = ''
    #!${stdenv.shell}
    ${dockerTools.shadowSetup}
    groupadd -r redis
    useradd -r -g redis -d /data -M redis
    mkdir /data
    chown redis:redis /data
  '';

  config = {
    Cmd = [ "${redis}/bin/redis-server" ];
    ExposedPorts = {
      "6379/tcp" = {};
    };
    WorkingDir = "/data";
    Volumes = {
      "/data" = {};
    };
  };
}

I don’t know if there’s something I’m doing wrong, or if there’s way to reduce the size of the docker image with nix?

Thanks.