From 294245f7501e0a8e69b83346a4fa5afd4ed33ab3 Mon Sep 17 00:00:00 2001 From: Philipp Joram Date: Fri, 5 Apr 2024 16:56:52 +0300 Subject: [PATCH] haskellPackages.Agda: Split outputs to reduce closure size After enabling a separate binary output for the `Agda` Haskell package, the new `bin` output measures ~100MiB, compared to the ~4.5GiB before. Using it in `agdaWithPackages` reduces the closure size of an Agda installation from ~5GiB to ~3GiB. The remaining space is taken up mostly by the GHC backend. With this change, derivations depending on `haskellPackages.Agda` directly need to pick the right (binary) output. This concerns in particular `emacsPackages.agda2-mode`. --- .../manual-packages/agda2-mode/default.nix | 12 +++++++----- pkgs/build-support/agda/default.nix | 7 ++++--- .../haskell-modules/configuration-nix.nix | 2 ++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/pkgs/applications/editors/emacs/elisp-packages/manual-packages/agda2-mode/default.nix b/pkgs/applications/editors/emacs/elisp-packages/manual-packages/agda2-mode/default.nix index 2533153bd447..7418a842148a 100644 --- a/pkgs/applications/editors/emacs/elisp-packages/manual-packages/agda2-mode/default.nix +++ b/pkgs/applications/editors/emacs/elisp-packages/manual-packages/agda2-mode/default.nix @@ -1,21 +1,23 @@ { trivialBuild , haskellPackages }: - -trivialBuild rec { +let + Agda = haskellPackages.Agda.bin; +in +trivialBuild { pname = "agda-mode"; - version = haskellPackages.Agda.version; + version = Agda.version; dontUnpack = true; # already byte-compiled by Agda builder buildPhase = '' - agda=`${haskellPackages.Agda}/bin/agda-mode locate` + agda=`${Agda}/bin/agda-mode locate` cp `dirname $agda`/*.el* . ''; meta = { - inherit (haskellPackages.Agda.meta) homepage license; + inherit (Agda.meta) homepage license; description = "Agda2-mode for Emacs extracted from Agda package"; longDescription = '' Wrapper packages that liberates init.el from `agda-mode locate` magic. diff --git a/pkgs/build-support/agda/default.nix b/pkgs/build-support/agda/default.nix index 44c9ade02ffb..b5d72d9ccf19 100644 --- a/pkgs/build-support/agda/default.nix +++ b/pkgs/build-support/agda/default.nix @@ -40,13 +40,14 @@ let allPackages = withPackages (filter self.lib.isUnbrokenAgdaPackage (attrValues self)); }; }; - inherit (Agda) meta; + # Agda is a split package with multiple outputs; do not inherit them here. + meta = removeAttrs Agda.meta [ "outputsToInstall" ]; } '' mkdir -p $out/bin - makeWrapper ${Agda}/bin/agda $out/bin/agda \ + makeWrapper ${Agda.bin}/bin/agda $out/bin/agda \ --add-flags "--with-compiler=${ghc}/bin/ghc" \ --add-flags "--library-file=${library-file}" - ln -s ${Agda}/bin/agda-mode $out/bin/agda-mode + ln -s ${Agda.bin}/bin/agda-mode $out/bin/agda-mode ''; withPackages = arg: if isAttrs arg then withPackages' arg else withPackages' { pkgs = arg; }; diff --git a/pkgs/development/haskell-modules/configuration-nix.nix b/pkgs/development/haskell-modules/configuration-nix.nix index 062b1767a7e4..5c655e2a5c1b 100644 --- a/pkgs/development/haskell-modules/configuration-nix.nix +++ b/pkgs/development/haskell-modules/configuration-nix.nix @@ -1073,6 +1073,8 @@ self: super: builtins.intersectAttrs super { # very useful. # Flag added in Agda 2.6.4.1, was always enabled before (enableCabalFlag "debug") + # Split outputs to reduce closure size + enableSeparateBinOutput ]; # ats-format uses cli-setup in Setup.hs which is quite happy to write