Skip to content

Rename pkg-def-overlays to pkg-def-extras #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ let
# and Nix expressions representing cabal packages (cabal-to-nix).
mkPkgSet =
{ pkg-def # Base package set. Either from stackage (via stack-to-nix) or from a cabal projects plan file (via plan-to-nix)
, pkg-def-overlays ? [] # Additional packages to augment the Base package set `pkg-def` with.
, pkg-def-extras ? [] # Additional packages to augment the Base package set `pkg-def` with.
, modules ? []
}@args:

Expand All @@ -67,35 +67,35 @@ let
# Create a Haskell package set based on a Stack configuration.
mkStackPkgSet =
{ stack-pkgs # Path to the output of stack-to-nix
, pkg-def-overlays ? []
, pkg-def-extras ? []
, modules ? []
}@args:

let
# The Stackage release referenced in the stack config
pkg-def = stackage.${stack-pkgs.resolver};
# The compiler referenced in the stack config
compiler = (stack-pkgs.overlay hackage).compiler or (pkg-def hackage).compiler;
compiler = (stack-pkgs.extras hackage).compiler or (pkg-def hackage).compiler;
in self.mkPkgSet {
inherit pkg-def;
pkg-def-overlays = [ stack-pkgs.overlay ] ++ pkg-def-overlays;
pkg-def-extras = [ stack-pkgs.extras ] ++ pkg-def-extras;
modules = [ ghcHackagePatches.${compiler.nix-name} ] ++ modules;
};

# Create a Haskell package set based on a Cabal configuration.
mkCabalProjectPkgSet =
{ plan-pkgs # Path to the output of plan-to-nix
, pkg-def-overlays ? []
, pkg-def-extras ? []
, modules ? []
}@args:

let
pkg-def = plan-pkgs.pkgs;
# The compiler referenced in the stack config
compiler = (plan-pkgs.overlay hackage).compiler or (pkg-def hackage).compiler;
compiler = (plan-pkgs.extras hackage).compiler or (pkg-def hackage).compiler;
in self.mkPkgSet {
inherit pkg-def;
pkg-def-overlays = [ plan-pkgs.overlay ] ++ pkg-def-overlays;
pkg-def-extras = [ plan-pkgs.extras ] ++ pkg-def-extras;
modules = [ ghcHackagePatches.${compiler.nix-name} ] ++ modules;
};

Expand Down
14 changes: 7 additions & 7 deletions docs/iohk-nix.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ iohk-nix.json
nix/pkgs.nix
```
{ pkgs ? import <nixpkgs> {}
, iohk-overlay ? {}
, iohk-extras ? {}
, iohk-module ? {}
, haskell
, hackage
Expand All @@ -67,16 +67,16 @@ let
# packages.cbors.patches = [ ./one.patch ];
# packages.cbors.flags.optimize-gmp = false;
#
compiler = (stack-pkgs.overlay hackage).compiler.nix-name;
compiler = (stack-pkgs.extras hackage).compiler.nix-name;
pkgSet = haskell.mkNewPkgSet {
inherit pkgs;
pkg-def = stackage.${stack-pkgs.resolver};
# The overlay allows extension or restriction of the set of
# packages we are interested in. By using the stack-pkgs.overlay
# These extras allow extension or restriction of the set of
# packages we are interested in. By using the stack-pkgs.extras
# we restrict our package set to the ones provided in stack.yaml.
pkg-def-overlays = [
stack-pkgs.overlay
iohk-overlay.${compiler}
pkg-def-extras = [
stack-pkgs.extras
iohk-extras.${compiler}
];
# package customizations
modules = [
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide-cabal.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ file as follows:
```nix
let plan = import ./plan.nix; in
{ pkg-def = plan;
overlay =
extras =
{ local-package-a = ./local-package-a.nix;
local-package-b = ./local-package-b.nix;
source-import-a = ./source-import-a.nix;
Expand Down
8 changes: 4 additions & 4 deletions docs/user-guide-stack.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This will produce a `nix/pkgs.nix` file that looks like the following:
```nix
{
resolver = "lts-12.17";
overlay = hackage:
extras = hackage:
{
packages = {
"o-clock" = hackage.o-clock."0.1.1".revisions.default;
Expand All @@ -30,9 +30,9 @@ This will produce a `nix/pkgs.nix` file that looks like the following:
}
```

This file contains the stackage resolver, as well as an overlay of
packages. The overlay specifies which `extra-deps` (here: o-clock-0.1.1)
we wanted to overlay over the stackage snapshot, and what local
This file contains the stackage resolver, as well as set of extra
packages. The extras specifies which `extra-deps` (here: o-clock-0.1.1)
we wanted to add over the stackage snapshot, and what local
packages we want (here: my-package).

*If you came here from the [User Guide](/user-guide), go back and
Expand Down
6 changes: 3 additions & 3 deletions docs/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ let
# Cabal projects use mkPkgSet
pkgSet = haskell.mkPkgSet {
pkg-def = my-pkgs.pkg-def;
pkg-def-overlays = [
# this overlay will provide additional packages
pkg-def-extras = [
# these extras will provide additional packages
# ontop of the package set. E.g. extra-deps
# for stack packages. or local packages for
# cabal.projects
my-pkgs.overlay
my-pkgs.extras
];
modules = [
# specific package overrides would go here
Expand Down
14 changes: 7 additions & 7 deletions package-set.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
let f = { hackage, pkgs, pkg-def, pkg-def-overlays ? [], modules ? [] }: let
buildModules = f { inherit hackage pkg-def pkg-def-overlays modules; pkgs = pkgs.buildPackages; };
let f = { hackage, pkgs, pkg-def, pkg-def-extras ? [], modules ? [] }: let
buildModules = f { inherit hackage pkg-def pkg-def-extras modules; pkgs = pkgs.buildPackages; };
in pkgs.lib.evalModules {
modules = modules ++ [
({ lib, ... }: {
Expand Down Expand Up @@ -33,7 +33,7 @@ in pkgs.lib.evalModules {
# or
# { y = ./foo.nix; }
# As such the desugarer desugars this short hand syntax.
let desugar = overlay:
let desugar = extras:
let
isPath = x: builtins.typeOf x == "path";
# rewrite
Expand All @@ -51,19 +51,19 @@ in pkgs.lib.evalModules {
# into
# x.revision = import ./some/path;
expand-paths = pkg: if !(isPath pkg.revision) then pkg else { revision = import pkg.revision; };
# apply injection and expansion to the "packages" in overlay.
# apply injection and expansion to the "packages" in extras.
in lib.mapAttrs (k: v: if k != "packages"
then v
else lib.mapAttrs (_: pkg: (expand-paths (inject-revision pkg))) v)
(inject-packages overlay);
# fold any potential `pkg-def-overlays`
(inject-packages extras);
# fold any potential `pkg-def-extras`
# onto the `pkg-def`.
#
# This means you can have a base definition (e.g. stackage)
# and augment it with custom packages to your liking.
in foldl' lib.recursiveUpdate
(pkg-def hackage)
(map (p: desugar (if builtins.isFunction p then p hackage else p)) pkg-def-overlays)
(map (p: desugar (if builtins.isFunction p then p hackage else p)) pkg-def-extras)
;

})
Expand Down
2 changes: 1 addition & 1 deletion test/builder-haddock/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let
# plan-to-nix dist-newstyle/cache/plan.json > plan.nix
# cabal-to-nix test-haddock.cabal > test-haddock.nix
pkg-def = import ./plan.nix;
pkg-def-overlays = [
pkg-def-extras = [
{ test-haddock = ./test-haddock.nix; }
];
modules = [
Expand Down
2 changes: 1 addition & 1 deletion test/cabal-22/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ with stdenv.lib;
let
pkgSet = mkPkgSet {
pkg-def = import ./plan.nix;
pkg-def-overlays = [
pkg-def-extras = [
{ project = ./project.nix; }
];
modules = [ ];
Expand Down
2 changes: 1 addition & 1 deletion test/cabal-simple/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let
# 3. plan-to-nix ./dist-newstyle/cache/plan.json > plan.nix
pkgSet = mkPkgSet {
pkg-def = import ./plan.nix;
pkg-def-overlays = [
pkg-def-extras = [
{ cabal-simple = ./cabal-simple.nix;
}
];
Expand Down
2 changes: 1 addition & 1 deletion test/cabal-sublib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let
# 3. plan-to-nix ./dist-newstyle/cache/plan.json > plan.nix
pkgSet = mkPkgSet {
pkg-def = import ./plan.nix;
pkg-def-overlays = [
pkg-def-extras = [
{ cabal-sublib = ./cabal-sublib.nix;
}
];
Expand Down
2 changes: 1 addition & 1 deletion test/stack-simple/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let
# generated by running hpack then stack-to-nix.
pkgSet = mkStackPkgSet {
stack-pkgs = import ./stack-pkgs.nix;
pkg-def-overlays = [];
pkg-def-extras = [];
modules = [];
};

Expand Down
4 changes: 2 additions & 2 deletions test/stack-simple/stack-pkgs.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
overlay = hackage:
extras = hackage:
{ packages = {} // { stack-simple = ./.stack.nix/stack-simple.nix; }; };
resolver = "lts-13.6";
}
}
2 changes: 1 addition & 1 deletion test/with-packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let
# plan-to-nix dist-newstyle/cache/plan.json > plan.nix
# cabal-to-nix test-with-packages.cabal > test-with-packages.nix
pkg-def = import ./plan.nix;
pkg-def-overlays = [
pkg-def-extras = [
{ test-with-packages = ./test-with-packages.nix; }
];
modules = [
Expand Down