Skip to content

Creating Docker images with dependent haskell-flakes #432

@khazaddum

Description

@khazaddum

I have project bar that is a library with a Rust FFI.

I have project foo that imports bar in the standard way:

perSystem = {
  ...
}: {
  haskellProjects.default = {
    imports = [
      inputs.bar.haskellFlakeProjectModules.output
    ];
    settings = {
      foo = {
        self,
        super,
        ...
      }: {
        justStaticExecutables = true;
        removeReferencesTo = [
          self.bar
        ];
      };
    };
  };
};

The Docker image derivation is:

        packages.dockerImage = pkgs.dockerTools.buildImage {
          name = "foo";
          created = "now";
          tag = "0.1";
          copyToRoot = pkgs.buildEnv {
            paths = with pkgs; [
              self'.packages.default
            ];
            name = "foo-root";
            pathsToLink = ["/bin"];
          };
          config = {
            Cmd = ["${self'.packages.default}/bin/foo"];
          };
        };

This produces an image that contains only executables and libraries for Haskell. It includes all the source of the Rust packages the bar library needs to build.

Any ideas on how to slim down this image?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions