I have a simple haskell project, I’d like to produce lightweight derivation.
My derivation is defined as follows:
packages.boom =
haskellPackages.callCabal2nix "boom" ./. rec {
# Dependency overrides go here
};
which produces:
$ tree -l result
result
├── bin
│ └── boom
├── lib
│ └── ghc-9.2.8
│ ├── package.conf.d
│ │ └── boom-0.1.0.0-1NOnniy5hO216ZQwgVFxMY.conf
│ └── x86_64-linux-ghc-9.2.8
│ ├── boom-0.1.0.0-1NOnniy5hO216ZQwgVFxMY
│ │ ├── Boom.dyn_hi
│ │ ├── Boom.hi
│ │ ├── Boom.p_hi
│ │ ├── libHSboom-0.1.0.0-1NOnniy5hO216ZQwgVFxMY.a
│ │ ├── libHSboom-0.1.0.0-1NOnniy5hO216ZQwgVFxMY_p.a
│ │ ├── Paths_boom.dyn_hi
│ │ ├── Paths_boom.hi
│ │ └── Paths_boom.p_hi
│ └── libHSboom-0.1.0.0-1NOnniy5hO216ZQwgVFxMY-ghc9.2.8.so
└── nix-support
└── propagated-build-inputs
8 directories, 12 files
$ du -hs result/*
880K result/bin
292K result/lib
4.0K result/nix-support
When I try to only build (or at least keep) dynamic binaries:
exeOnly = b:
with pkgs.haskell.lib;
enableSharedExecutables (enableSharedLibraries
(disableStaticLibraries (disableExecutableProfiling b)));
# ...
defaultPackage = exeOnly packages.boom;
only binaries are are affected:
$ tree -l result
result
├── bin
│ └── boom
├── lib
│ └── ghc-9.2.8
│ ├── package.conf.d
│ │ └── boom-0.1.0.0-1NOnniy5hO216ZQwgVFxMY.conf
│ └── x86_64-linux-ghc-9.2.8
│ ├── boom-0.1.0.0-1NOnniy5hO216ZQwgVFxMY
│ │ ├── Boom.dyn_hi
│ │ ├── Boom.hi
│ │ ├── Boom.p_hi
│ │ ├── libHSboom-0.1.0.0-1NOnniy5hO216ZQwgVFxMY.a
│ │ ├── libHSboom-0.1.0.0-1NOnniy5hO216ZQwgVFxMY_p.a
│ │ ├── Paths_boom.dyn_hi
│ │ ├── Paths_boom.hi
│ │ └── Paths_boom.p_hi
│ └── libHSboom-0.1.0.0-1NOnniy5hO216ZQwgVFxMY-ghc9.2.8.so
└── nix-support
└── propagated-build-inputs
8 directories, 12 files
$ du -hs result/*
20K result/bin
292K result/lib
4.0K result/nix-support
It should not keep *.a
, *.hi
, *.p_hi
, (and maybe *.dyn_hi
.
So, there’s two compilations:
boom> building
boom> Preprocessing library for boom-0.1.0.0..
boom> Building library for boom-0.1.0.0..
boom> [1 of 2] Compiling Boom ( src/Boom.hs, dist/build/Boom.o, dist/build/Boom.dyn_o )
boom> [2 of 2] Compiling Paths_boom ( dist/build/autogen/Paths_boom.hs, dist/build/Paths_boom.o, dist/build/Paths_boom.dyn_o )
boom> [1 of 2] Compiling Boom ( src/Boom.hs, dist/build/Boom.p_o )
boom> [2 of 2] Compiling Paths_boom ( dist/build/autogen/Paths_boom.hs, dist/build/Paths_boom.p_o )
Are there other options to remove (or don’t compile) useless files for runtime?
Thanks in advance.