@@ -385,7 +385,11 @@ let
385385 LANG = "en_US.UTF-8";
386386 meta.platforms = pkgs.lib.platforms.all;
387387 preferLocalBuild = false;
388− outputs = ["out" "json"];
388+ outputs = [
389+ "out" # The results of plan-to-nix
390+ "json" # The `plan.json` file generated by cabal and used for `plan-to-nix` input
391+ "freeze" # The `cabal.project.freeze` file created by `cabal v2-freeze`
392+ ];
389393 } ''
390394 tmp=$(mktemp -d)
391395 cd $tmp
@@ -421,10 +425,15 @@ let
421425 ${pkgs.lib.optionalString (cabalProjectFreeze != null) ''
422426 cp ${pkgs.evalPackages.writeText "cabal.project.freeze" cabalProjectFreeze} \
423427 cabal.project.freeze
428+ chmod +w cabal.project.freeze
424429 ''}
425430 export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
426431 export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
427432
433+ # Using `cabal v2-freeze` will configure the project (since
434+ # it is not configured yet), taking the existing `cabal.project.freeze`
435+ # file into account. Then it "writes out a freeze file which
436+ # records all of the versions and flags that are picked" (from cabal docs).
428437 echo "Using index-state ${index-state-found}"
429438 HOME=${
430439 # This creates `.cabal` directory that is as it would have
@@ -436,7 +445,7 @@ let
436445 index-state = cached-index-state;
437446 sha256 = index-sha256-found;
438447 }
439− } cabal v2-configure \
448+ } cabal v2-freeze \
440449 --index-state=${
441450 # Setting the desired `index-state` here in case it was not
442451 # from the cabal.project file. This will further restrict the
@@ -453,6 +462,10 @@ let
453462 "--ghcjs --with-ghcjs=js-unknown-ghcjs-ghc --with-ghcjs-pkg=js-unknown-ghcjs-ghc-pkg"} \
454463 ${configureArgs}
455464
465+ cp cabal.project.freeze $freeze
466+ # Not needed any more (we don't want it to wind up in the $out hash)
467+ rm cabal.project.freeze
468+
456469 mkdir -p $out
457470
458471 # ensure we have all our .cabal files (also those generated from package.yaml) files.