Skip to content

Commit 116bb3a

Browse files
committed
Merge branch 'master' of github.com:input-output-hk/haskell.nix into feature/pkg-def-extras
2 parents cded0d6 + de64d0c commit 116bb3a

File tree

8 files changed

+41
-68
lines changed

8 files changed

+41
-68
lines changed

builder/comp-builder.nix

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ stdenv, buildPackages, ghc, lib, pkgconfig, writeText, runCommand, haskellLib, nonReinstallablePkgs, withPackage }:
1+
{ stdenv, buildPackages, ghc, lib, pkgconfig, writeText, runCommand, haskellLib, nonReinstallablePkgs, withPackage, hsPkgs }:
22

33
{ componentId
44
, component
@@ -9,6 +9,7 @@
99
, flags
1010
, revision
1111
, cabalFile
12+
, cabal-generator
1213
, patches ? []
1314

1415
, preUnpack ? null, postUnpack ? null
@@ -187,7 +188,9 @@ let
187188
# the target dir for haddock documentation
188189
docdir = docoutput: docoutput + "/share/doc/" + componentId.cname;
189190

190-
doHaddock' = doHaddock && (haskellLib.isLibrary componentId);
191+
doHaddock' = doHaddock
192+
&& (haskellLib.isLibrary componentId)
193+
&& stdenv.hostPlatform == stdenv.buildPlatform;
191194

192195
in stdenv.lib.fix (drv:
193196

@@ -240,9 +243,11 @@ stdenv.mkDerivation ({
240243
# Phases
241244
preInstallPhases = lib.optional doHaddock' "haddockPhase";
242245

243-
prePatch = lib.optionalString (cabalFile != null) ''
244-
cat ${cabalFile} > ${package.identifier.name}.cabal
245-
'';
246+
prePatch = if (cabalFile != null)
247+
then ''cat ${cabalFile} > ${package.identifier.name}.cabal''
248+
else lib.optionalString (cabal-generator == "hpack") ''
249+
${hsPkgs.hpack.components.exes.hpack}/bin/hpack
250+
'';
246251

247252
configurePhase = ''
248253
runHook preConfigure

builder/default.nix

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
{ pkgs, buildPackages, stdenv, lib, haskellLib, ghc, buildGHC, fetchurl, writeText, runCommand, pkgconfig, nonReinstallablePkgs, withPackage }:
1+
{ pkgs, buildPackages, stdenv, lib, haskellLib, ghc, buildGHC, fetchurl, writeText, runCommand, pkgconfig, nonReinstallablePkgs, withPackage, hsPkgs }:
22

33
{ flags
44
, package
55
, components
6+
, cabal-generator
67

78
, name
89
, sha256
@@ -71,10 +72,10 @@ let
7172
'';
7273
};
7374

74-
comp-builder = haskellLib.weakCallPackage pkgs ./comp-builder.nix { inherit ghc haskellLib nonReinstallablePkgs withPackage; };
75+
comp-builder = haskellLib.weakCallPackage pkgs ./comp-builder.nix { inherit ghc haskellLib nonReinstallablePkgs withPackage hsPkgs; };
7576

7677
buildComp = componentId: component: comp-builder {
77-
inherit componentId component package name src flags setup cabalFile patches revision
78+
inherit componentId component package name src flags setup cabalFile cabal-generator patches revision
7879
preUnpack postUnpack preConfigure postConfigure
7980
preBuild postBuild preCheck postCheck
8081
preInstall postInstall preHaddock postHaddock

docs/user-guide-cabal.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ file as follows:
4949

5050
```nix
5151
let plan = import ./plan.nix; in
52-
{ ... }:
5352
{ pkg-def = plan;
5453
overlay =
5554
{ local-package-a = ./local-package-a.nix;

docs/user-guide-stack.md

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,5 @@ packages. The overlay specifies which `extra-deps` (here: o-clock-0.1.1)
3535
we wanted to overlay over the stackage snapshot, and what local
3636
packages we want (here: my-package).
3737

38-
We will then create the following `nix/default.nix` file:
39-
40-
```nix
41-
{ pkgs ? import <nixpkgs> {} }:
42-
43-
let
44-
haskell = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) { inherit pkgs; };
45-
46-
pkgSet = haskell.mkStackPkgSet {
47-
stack-pkgs = import ./pkgs.nix;
48-
pkg-def-extras = [];
49-
modules = [];
50-
};
51-
52-
in
53-
pkgSet.config.hsPkgs
54-
```
55-
56-
This generated file is a template, so you can customize it as
57-
necessary.
58-
5938
*If you came here from the [User Guide](/user-guide), go back and
6039
complete the setup.*

docs/user-guide.md

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -35,41 +35,23 @@ let
3535
in
3636
```
3737

38-
Next we will use this to import `haskell.nix`, `hackage.nix` and
39-
`stackage.nix` (if we use a stack project).
38+
Next we will use this to import `haskell.nix`.
4039

4140
**NOTE**: update the `rev` and `sha256` values to the recent ones as
42-
found on GitHub. Especially `hackage.nix` and `stackage.nix` will
43-
evolve with package release on hackage and stackage releases
41+
found on GitHub. Especially `haskell.hackage` and `haskell.stackage`
42+
will evolve with package release on hackage and stackage releases
4443
respectively.
4544

4645
```nix
4746
let
48-
# all packages from hackage as nix expressions
49-
hackage = import (overrideWith "hackage"
50-
(pkgs.fetchFromGitHub { owner = "input-output-hk";
51-
repo = "hackage.nix";
52-
rev = "3180384b563ec7c7b46bca86b3ace0f32d04cde8";
53-
sha256 = "19ndkn8pivli9plwq0wnx1cj126l89yk7jw9a0dj51ic3b2qhlb2";
54-
name = "hackage-exprs-source"; }))
55-
;
56-
# a different haskell infrastructure
57-
haskell = import (overrideWith "haskell"
58-
(pkgs.fetchFromGitHub { owner = "input-output-hk";
59-
repo = "haskell.nix";
60-
rev = "73f733ba8bbd11443dda713d1a2d4b7c50a5d408";
61-
sha256 = "1p2srrxw2lac5krrg35waa251by98r2miwyg6zac9glpg2vmq3ip";
62-
name = "haskell-lib-source"; }))
63-
hackage;
64-
65-
# the set of all stackage snapshots
66-
stackage = import (overrideWith "stackage"
67-
(pkgs.fetchFromGitHub { owner = "input-output-hk";
68-
repo = "stackage.nix";
69-
rev = "2615a4e6b1651215ee400e62fcdcb195062a3d35";
70-
sha256 = "08c8lb8x047hndwm1cb2zxixnjmrswfp5y18xp1v79cjqlva0qj6";
71-
name = "stackage-snapshot-source"; }))
72-
;
47+
haskellLib = pkgs.fetchFromGitHub {
48+
owner = "input-output-hk";
49+
repo = "haskell.nix";
50+
rev = "5180ae9d78756509c81b98b8e6d974e350b15752";
51+
sha256 = "0fbnnvymdp2qb09wlqy6ga8wsyhglx607cjdfg510s1gs756v9yx";
52+
name = "haskell-lib-source";
53+
};
54+
haskell = import (overrideWith "haskell" haskellLib) { inherit pkgs; };
7355
in
7456
```
7557

@@ -78,10 +60,17 @@ Finally we string this together and produce a package set:
7860
```nix
7961
let
8062
# Import the file you will create in the stack-to-nix or cabal-to-nix step.
81-
my-pkgs = import ./nix/pkgs.nix { inherit stackage; };
63+
my-pkgs = import ./nix/pkgs.nix;
64+
65+
# Stack projects use the mkStackPkgSet helper function
66+
pkgSet = haskell.mkStackPkgSet {
67+
stack-pkgs = my-pkgs;
68+
pkg-def-overlays = [];
69+
modules = [];
70+
};
8271
72+
# Cabal projects use mkPkgSet
8373
pkgSet = haskell.mkPkgSet {
84-
inherit pkgs;
8574
pkg-def = my-pkgs.pkg-def;
8675
pkg-def-extras = [
8776
# this overlay will provide additional packages

hackage-src.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"url": "https://github.com/input-output-hk/hackage.nix",
3-
"rev": "3180384b563ec7c7b46bca86b3ace0f32d04cde8",
4-
"date": "2019-02-05T17:32:14+08:00",
5-
"sha256": "19ndkn8pivli9plwq0wnx1cj126l89yk7jw9a0dj51ic3b2qhlb2",
3+
"rev": "bae1e9533d0b389218dae18a011f61bb89913058",
4+
"date": "2019-03-04T17:30:54+01:00",
5+
"sha256": "0qyhzliwanvlkwgfl08s2wiibdy2pv2jr4pdgndvgk1qh3ihy0gx",
66
"fetchSubmodules": false
77
}

modules/component-driver.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let
55
inherit haskellLib;
66
ghc = config.ghc.package;
77
buildGHC = buildModules.config.ghc.package;
8-
inherit (config) nonReinstallablePkgs;
8+
inherit (config) nonReinstallablePkgs hsPkgs;
99
inherit withPackage;
1010
};
1111

stackage-src.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"url": "https://github.com/input-output-hk/stackage.nix",
3-
"rev": "2615a4e6b1651215ee400e62fcdcb195062a3d35",
4-
"date": "2019-02-05T17:41:44+08:00",
5-
"sha256": "08c8lb8x047hndwm1cb2zxixnjmrswfp5y18xp1v79cjqlva0qj6",
3+
"rev": "1d992021163db62c064fe704730f8aff79fbac2b",
4+
"date": "2019-03-04T17:30:33+01:00",
5+
"sha256": "0dxb93bpfjcgc83j1asi23r7yn8fcc456sjn5diblkj0vy7wjg43",
66
"fetchSubmodules": false
77
}

0 commit comments

Comments
 (0)