I am building a Docker image in which I want to bundle multiple executables. Each executable is defined in a different package, in my case pandoc
, pandoc-citeproc
, and pandoc-crossref
. The build should be as reproducible as reasonably possible on a Debian/Ubuntu based system.
What I'd like to do is use (something like) a cabal.project.freeze file to ensure that all subsequent builds will use the same packages.
I'm aware that I can fix the version of the executables:
cabal v2-install pandoc-2.7.3 pandoc-citeproc-0.16.2 pandoc-crossref-0.3.4.1
But this will not fix the versions of transitive dependencies, so rebuilding at different times may lead to subtly different build results. Can I somehow create and use a freeze file in this setup? Using v2-freeze seems to be of no use here:
$ cabal new-freeze pandoc-2.7.3 pandoc-citeproc-0.16.2 pandoc-crossref-0.3.4.1
cabal: 'freeze' doesn't take any extra arguments: pandoc-2.7.3
pandoc-citeproc-0.16.2 pandoc-crossref-0.3.4.1
Okay, there might be a better built-in way to do this kind of thing, but here's a hacky workaround that might be suitable for you until a real cabal expert comes along.
The basic plan will be this: temporarily create a project with the three packages you care about -- just long enough to get a freeze file -- then use some simple text-editor macros to turn the freeze file into a
v2-install
command. So:Woof, that last one is a mouthful. It says:
You could also do these manually in an editor if you wanted. At the end of this process, which you can run in a temporary directory to ease cleanup afterwards, you should have a file named
cabal-v2-install.sh
with a command that will select the exact same versions and flags for all packages involved, including dependencies.