From 335f1fb25f2f784e496dc4e5560cea7e3414a7a8 Mon Sep 17 00:00:00 2001 From: Joe Kachmar Date: Mon, 11 Jan 2021 17:47:24 -0500 Subject: [PATCH 1/2] Adds Haskell generic builder argument modifier This is a new argument to the Haskell builder's 'shellFor' which allows the caller to adjust the 'genericBuilderArgs' after they are built. One immediate application for this is that it allows users to disable tests, enable benchmarks, etc. for _all_ packages in a given Haskell package set. This is often useful when so many of the derivations in the package set have changed that most of the cache has been invalidated, and there is no need for the user to run tests on their dependencies, but they still want these dependencies available in their 'nix-shell' environment for some package-under-development. --- pkgs/development/haskell-modules/make-package-set.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/development/haskell-modules/make-package-set.nix b/pkgs/development/haskell-modules/make-package-set.nix index 4ae3f0b2427..c6b9f1021bc 100644 --- a/pkgs/development/haskell-modules/make-package-set.nix +++ b/pkgs/development/haskell-modules/make-package-set.nix @@ -323,6 +323,7 @@ in package-set { inherit pkgs stdenv callPackage; } self // { # packages. You should set this to true if you have benchmarks defined # in your local packages that you want to be able to run with cabal benchmark doBenchmark ? false + , genericBuilderArgsModifier ? (args: args) , ... } @ args: let @@ -439,7 +440,7 @@ in package-set { inherit pkgs stdenv callPackage; } self // { # This is a derivation created with `haskellPackages.mkDerivation`. # # pkgWithCombinedDeps :: HaskellDerivation - pkgWithCombinedDeps = self.mkDerivation genericBuilderArgs; + pkgWithCombinedDeps = self.mkDerivation (genericBuilderArgsModifier genericBuilderArgs); # The derivation returned from `envFunc` for `pkgWithCombinedDeps`. # @@ -453,7 +454,7 @@ in package-set { inherit pkgs stdenv callPackage; } self // { # pkgWithCombinedDepsDevDrv :: Derivation pkgWithCombinedDepsDevDrv = pkgWithCombinedDeps.envFunc { inherit withHoogle; }; - mkDerivationArgs = builtins.removeAttrs args [ "packages" "withHoogle" "doBenchmark" ]; + mkDerivationArgs = builtins.removeAttrs args [ "genericBuilderArgsModifier" "packages" "withHoogle" "doBenchmark" ]; in pkgWithCombinedDepsDevDrv.overrideAttrs (old: mkDerivationArgs // { nativeBuildInputs = old.nativeBuildInputs ++ mkDerivationArgs.nativeBuildInputs or []; From 95d0e6c1b8adca3a03c5e79fc1dba84b5c1f68d6 Mon Sep 17 00:00:00 2001 From: Joe Kachmar Date: Thu, 14 Jan 2021 11:36:42 -0500 Subject: [PATCH 2/2] Adds Haskell generic args builder documentation --- .../haskell-modules/make-package-set.nix | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/pkgs/development/haskell-modules/make-package-set.nix b/pkgs/development/haskell-modules/make-package-set.nix index c6b9f1021bc..9aa353aac13 100644 --- a/pkgs/development/haskell-modules/make-package-set.nix +++ b/pkgs/development/haskell-modules/make-package-set.nix @@ -323,6 +323,36 @@ in package-set { inherit pkgs stdenv callPackage; } self // { # packages. You should set this to true if you have benchmarks defined # in your local packages that you want to be able to run with cabal benchmark doBenchmark ? false + # An optional function that can modify the generic builder arguments + # for the fake package that shellFor uses to construct its environment. + # + # Example: + # let + # # elided... + # haskellPkgs = pkgs.haskell.packages.ghc884.override (hpArgs: { + # overrides = pkgs.lib.composeExtensions (hpArgs.overrides or (_: _: { })) ( + # _hfinal: hprev: { + # mkDerivation = args: hprev.mkDerivation ({ + # doCheck = false; + # doBenchmark = false; + # doHoogle = true; + # doHaddock = true; + # enableLibraryProfiling = false; + # enableExecutableProfiling = false; + # } // args); + # } + # ); + # }); + # in + # hpkgs.shellFor { + # packages = p: [ p.foo ]; + # genericBuilderArgsModifier = args: args // { doCheck = true; doBenchmark = true }; + # } + # + # This will disable tests and benchmarks for everything in "haskellPkgs" + # (which will invalidate the binary cache), and then re-enable them + # for the "shellFor" environment (ensuring that any test/benchmark + # dependencies for "foo" will be available within the nix-shell). , genericBuilderArgsModifier ? (args: args) , ... } @ args: