From 9f48a9fe6cafdd5ec63ab2a2dd68a4d101a79600 Mon Sep 17 00:00:00 2001 From: Torsten Schmits Date: Sun, 8 Oct 2023 17:05:13 +0200 Subject: [PATCH] Separate the effect of the option `profiling` from `env..localPackage` --- changelog.md | 1 + lib/deps/local.nix | 8 +++++--- modules/env.nix | 11 ++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/changelog.md b/changelog.md index f31a058c..a4360d0e 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,7 @@ * Add the option `haskellTools` globally and per-env, which allows specifying shell tools that should be made available from the env's GHC without overrides. +* Separate the effect of the option `profiling` from `env..localPackage`. # 0.6.7 diff --git a/lib/deps/local.nix b/lib/deps/local.nix index 6d553802..a626172e 100644 --- a/lib/deps/local.nix +++ b/lib/deps/local.nix @@ -2,12 +2,14 @@ config, lib, ifd, - localPackage ? _: lib.id, + profiling, + localPackage, }: with lib; let cabalDrv = import ../cabal-drv.nix { inherit config lib; }; - c2n = import ./cabal2nix.nix { inherit (config) pkgs; }; + + localProfiling = api: if profiling then id else api.noprofiling; buildInputs = api: opt: if isFunction opt @@ -16,7 +18,7 @@ let override = api: pkg: drv: api.buildInputs (buildInputs api config.buildInputs) - (api.buildInputs (buildInputs api pkg.buildInputs) (pkg.override api (localPackage api drv))); + (api.buildInputs (buildInputs api pkg.buildInputs) (pkg.override api (localPackage api (localProfiling api drv)))); checkIfd = api: name: pkg: if ifd diff --git a/modules/env.nix b/modules/env.nix index ed7d92b6..4648bfa5 100644 --- a/modules/env.nix +++ b/modules/env.nix @@ -381,17 +381,15 @@ in { localPackage = mkOption { description = mdDoc '' - A function that takes dep combinators and a derivation and returns a modified version of that derivation. + A function that takes override combinators and a derivation and returns a modified version of that derivation. Called for each cabal2nix derivation of the local packages before inserting it into the overrides. - - The default is to disable profiling if [](#opt-env-profiling) is `false`. - If this option is customized, the profiling option won't be effective. + Like [](#opt-general-overrides), but applies too all packages when building with this env. ''; example = literalExpression '' { fast, nobench, ... }: pkg: nobench (fast pkg); ''; type = unspecified; - default = api: if config.profiling then id else api.noprofiling; + default = api: id; }; profiling = mkOption { @@ -399,7 +397,6 @@ in { default = true; description = mdDoc '' Whether to build local packages and dependency overrides with profiling enabled. - Ineffective if [](#opt-env-localPackage) is customized. ''; }; @@ -508,7 +505,7 @@ in { default = import ../lib/deps/local.nix { config = global; inherit lib; - inherit (config) ifd localPackage; + inherit (config) ifd localPackage profiling; }; };