Stream: haskell-flake

Topic: Creating Docker image from with Rust FFI


view this post on Zulip Rene Vergara (Jun 18 2025 at 21:34):

Hello,

I have a haskell-flake library bar that has a Rust FFI using the settings.<name>.custom property to link everything.

I have an app foo that depends on bar. When trying to create a Docker image per the docs, the image is huge. When following the instructions in the docs to reduce the size, the Haskell portions get reduced but the image still contains all the Rust deps needed to build bar. Is there a way to avoid packing all the Rust code?

view this post on Zulip Shivaraj B H (Jun 19 2025 at 06:22):

You might have to removeReferencesTo unwanted deps of bar. But first, it would be helpful to see how the image depends on these unwanted deps using nix why-depends

view this post on Zulip Srid (Jun 19 2025 at 07:43):

Meta: same question https://github.com/srid/haskell-flake/discussions/433

view this post on Zulip Rene Vergara (Jun 19 2025 at 13:02):

I am using removeReferencesTo. The original Docker image was much larger and it included ghc and all the Haskell deps. removeReferencesTo did remove all of the Haskell deps, but I am left with all the Rust dependencies still.

view this post on Zulip Rene Vergara (Jun 19 2025 at 15:38):

The dependencies that remain in the image are the ones brought in by the derivation that the bar lib uses via settings.<name>.custom

view this post on Zulip Rene Vergara (Jun 20 2025 at 18:55):

I was able to remove these using removeReferencesTo by explicitly calling out the Rust derivations, not just bar.

view this post on Zulip Shivaraj B H (Jun 21 2025 at 07:13):

I should include this use case in https://github.com/shivaraj-bh/haskell-rust-ffi-template and also update https://nixos.asia/en/haskell-rust-ffi


Last updated: Jul 06 2025 at 09:18 UTC