Skip to content

Commit

Permalink
Separate the effect of the option profiling from `env.<name>.localP…
Browse files Browse the repository at this point in the history
…ackage`
  • Loading branch information
tek committed Oct 8, 2023
1 parent 2b4d5e7 commit 9f48a9f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.<name>.localPackage`.

# 0.6.7

Expand Down
8 changes: 5 additions & 3 deletions lib/deps/local.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
11 changes: 4 additions & 7 deletions modules/env.nix
Original file line number Diff line number Diff line change
Expand Up @@ -381,25 +381,22 @@ 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 {
type = bool;
default = true;
description = mdDoc ''
Whether to build local packages and dependency overrides with profiling enabled.
Ineffective if [](#opt-env-localPackage) is customized.
'';
};

Expand Down Expand Up @@ -508,7 +505,7 @@ in {
default = import ../lib/deps/local.nix {
config = global;
inherit lib;
inherit (config) ifd localPackage;
inherit (config) ifd localPackage profiling;
};
};

Expand Down

0 comments on commit 9f48a9f

Please sign in to comment.