-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
Closed
Labels
0.kind: questionRequests for a specific question to be answeredRequests for a specific question to be answered6.topic: closure sizeThe final size of a derivation, including its dependenciesThe final size of a derivation, including its dependencies6.topic: haskellGeneral-purpose, statically typed, purely functional programming languageGeneral-purpose, statically typed, purely functional programming language
Description
I have the following default.nix:
let
nixpkgs = import (fetchTarball https://github.com/nixos/nixpkgs/archive/21.11.tar.gz) {};
in
nixpkgs.haskellPackages.callCabal2nix "test" ./. {}
And test.cabal looks like this:
cabal-version: 1.12
name: test
version: 0.1.0.0
library lib
exposed-modules: Lib
build-depends: base
executable test
main-is: Main.hs
build-depends: base, lib
Then I use docker.nix to build a docker image:
let
nixpkgs = import (fetchTarball https://github.com/nixos/nixpkgs/archive/21.11.tar.gz) {};
in nixpkgs.dockerTools.buildLayeredImage {
name = "test";
contents = import ./default.nix;
}
The resulting docker image is almost 400 MB, and contains ghc, gcc, documentation, and so on. However, if I remove the library from the cabal file, the resulting docker image is only 14 MB, and doesn't contain anything superfluous. I guess that when the cabal file contains a library, it becomes part of the build result, and since a library isn't useful on its own, it depends on ghc? However, I don't want to make the library available, it's only for building the executable. How can I get a lean docker image without a build environment, while keeping the library structure of the cabal project?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
0.kind: questionRequests for a specific question to be answeredRequests for a specific question to be answered6.topic: closure sizeThe final size of a derivation, including its dependenciesThe final size of a derivation, including its dependencies6.topic: haskellGeneral-purpose, statically typed, purely functional programming languageGeneral-purpose, statically typed, purely functional programming language