Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ba4c91d6b144
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 57c9485e7bfb
Choose a head ref
  • 4 commits
  • 4 files changed
  • 2 contributors

Commits on Nov 13, 2020

  1. Copy the full SHA
    29dc127 View commit details
  2. Copy the full SHA
    be91d93 View commit details
  3. Copy the full SHA
    6586a9c View commit details
  4. Merge pull request #103061 from expipiplus1/joe-hoogle

    haskell: Add hoogle option to developPackage
    cdepillabout authored Nov 13, 2020
    Copy the full SHA
    57c9485 View commit details
Showing with 51 additions and 5 deletions.
  1. +2 −2 lib/default.nix
  2. +10 −1 lib/fixed-points.nix
  3. +20 −0 lib/tests/misc.nix
  4. +19 −2 pkgs/development/haskell-modules/make-package-set.nix
4 changes: 2 additions & 2 deletions lib/default.nix
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
*/
let

inherit (import ./fixed-points.nix {}) makeExtensible;
inherit (import ./fixed-points.nix { inherit lib; }) makeExtensible;

lib = makeExtensible (self: let
callLibs = file: import file { lib = self; };
@@ -69,7 +69,7 @@ let
importJSON importTOML warn info showWarnings nixpkgsVersion version mod compare
splitByAndCompare functionArgs setFunctionArgs isFunction toHexString toBaseDigits;
inherit (self.fixedPoints) fix fix' converge extends composeExtensions
makeExtensible makeExtensibleWithCustomName;
composeManyExtensions makeExtensible makeExtensibleWithCustomName;
inherit (self.attrsets) attrByPath hasAttrByPath setAttrByPath
getAttrFromPath attrVals attrValues getAttrs catAttrs filterAttrs
filterAttrsRecursive foldAttrs collect nameValuePair mapAttrs
11 changes: 10 additions & 1 deletion lib/fixed-points.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ ... }:
{ lib, ... }:
rec {
# Compute the fixed point of the given function `f`, which is usually an
# attribute set that expects its final, non-recursive representation as an
@@ -77,6 +77,15 @@ rec {
super' = super // fApplied;
in fApplied // g self super';

# Compose several extending functions of the type expected by 'extends' into
# one where changes made in preceding functions are made available to
# subsequent ones.
#
# composeManyExtensions : [packageSet -> packageSet -> packageSet] -> packageSet -> packageSet -> packageSet
# ^final ^prev ^overrides ^final ^prev ^overrides
composeManyExtensions =
lib.foldr (x: y: composeExtensions x y) (self: super: {});

# Create an overridable, recursive attribute set. For example:
#
# nix-repl> obj = makeExtensible (self: { })
20 changes: 20 additions & 0 deletions lib/tests/misc.nix
Original file line number Diff line number Diff line change
@@ -87,6 +87,26 @@ runTests {
expected = true;
};

testComposeManyExtensions0 = {
expr = let obj = makeExtensible (self: { foo = true; });
emptyComposition = composeManyExtensions [];
composed = obj.extend emptyComposition;
in composed.foo;
expected = true;
};

testComposeManyExtensions =
let f = self: super: { bar = false; baz = true; };
g = self: super: { bar = super.baz or false; };
h = self: super: { qux = super.bar or false; };
obj = makeExtensible (self: { foo = self.qux; });
in {
expr = let composition = composeManyExtensions [f g h];
composed = obj.extend composition;
in composed.foo;
expected = (obj.extend (composeExtensions f (composeExtensions g h))).foo;
};

testBitAnd = {
expr = (bitAnd 3 10);
expected = 2;
21 changes: 19 additions & 2 deletions pkgs/development/haskell-modules/make-package-set.nix
Original file line number Diff line number Diff line change
@@ -221,30 +221,47 @@ in package-set { inherit pkgs stdenv callPackage; } self // {
# , overrides : Defaulted (HaskellPackageOverrideSet)
# , modifier : Defaulted
# , returnShellEnv : Defaulted
# , withHoogle : Defaulted
# } -> NixShellAwareDerivation
# Given a path to a haskell package directory, an optional package name
# which defaults to the base name of the path, an optional set of source
# overrides as appropriate for the 'packageSourceOverrides' function, an
# optional set of arbitrary overrides, and an optional haskell package
# modifier, return a derivation appropriate for nix-build or nix-shell to
# build that package.
# If 'returnShellEnv' is true this returns a derivation which will give you
# an environment suitable for developing the listed packages with an
# incremental tool like cabal-install.
# If 'withHoogle' is true (the default if a shell environment is requested)
# then 'ghcWithHoogle' is used to generate the derivation (instead of
# 'ghcWithPackages'), see the documentation there for more information.
developPackage =
{ root
, name ? builtins.baseNameOf root
, source-overrides ? {}
, overrides ? self: super: {}
, modifier ? drv: drv
, returnShellEnv ? pkgs.lib.inNixShell }:
, returnShellEnv ? pkgs.lib.inNixShell
, withHoogle ? returnShellEnv }:
let drv =
(extensible-self.extend
(pkgs.lib.composeExtensions
(self.packageSourceOverrides source-overrides)
overrides))
.callCabal2nix name root {};
in if returnShellEnv then (modifier drv).env else modifier drv;
in if returnShellEnv
then (modifier drv).envFunc {inherit withHoogle;}
else modifier drv;

ghcWithPackages = selectFrom: withPackages (selectFrom self);

# Put 'hoogle' into the derivation's PATH with a database containing all
# the package's dependencies; run 'hoogle server --local' in a shell to
# host a search engine for the dependencies.
#
# To reload the Hoogle server automatically on .cabal file changes try
# this:
# echo *.cabal | entr -r -- nix-shell --run 'hoogle server --local'
ghcWithHoogle = selectFrom:
let
packages = selectFrom self;