Commit Graph

79 Commits

Author SHA1 Message Date
Rodney Lorrimar
686fa37877
shellFor: Fix bug where packages were not excluded from the env (#285)
* tests: Add regression test for shellFor build-tools bug

* tests: Fix regen script

* Regenerate nix expressions for tests

* tests: ghc 8.4.4 -> 8.6.5

* shellFor: Fix bug where packages were not excluded from the env

If a multi-package project had an build-tools dependency between
packages, they would not be correctly removed from the shell's inputs.
2019-11-01 20:08:31 +10:00
Hamish Mackenzie
a5f9f45922
Test setup deps issue depending on ghc and Cabal (#278)
Projects like asterius and leksah that include dependencies on ghc. Sometimes the are needed by a setup.hs file (as is the case for the binaryen package used by asterius). The recent overlays merge broke this and #279 was needed to allow reinstallableLibGhc to be used to fix it. This PR adds a test case to make sure it is not inadvertently broken again. Also gives us a place to try out better ways to make this type of package work.* Test setup deps issue depending on ghc and Cabal

* Uses nixpkgs 19.09 + macOS wine fix on hydra/buildkite

* Enables macOS hydra tests

* disables musl tests for now

* Adds haskellNixRoots to tests

* Uses reinstallableLibGhc to fix the new setup-depends test

* Adds meta.platforms to haskell.nix components

* Set meta.platforms on cabal-install

* Builds some maintainer-scripts on hydra

* Pins hackage index-state for ghc-extra-packages
2019-11-01 12:34:10 +13:00
Hamish Mackenzie
e15c59ba2e
Give more control over the compilation of Setup.hs (#277)
Allows adding of overrides through package.components.setup.
I need this to specify frameworks that Setup.hs needs on macOS.
2019-10-31 19:15:07 +13:00
Hamish Mackenzie
46fad81954 Considerate/overlays fixes (#262)
* Fix loadArchive clang++ error on macOS

GHC 8.6.4 introduced an issue where linking to `-libc++` will cause
GHC to resolve the library path to `c++` which in turn is a link to
clang++. This results in the following error:

```
ghc: loadArchive: Neither an archive, nor a fat archive: `/nix/store/?-clang-wrapper-5.0.2/bin/clang++'

<no location info>: error:
    loadArchive "/nix/store/?-clang-wrapper-5.0.2/bin/clang++": failed
```

The provided patch reverts the linking behavior of GHC to not resolve
`-libc++` to `c++`.

* Propagate unpack hooks to setup
2019-10-22 17:15:10 +08:00
Moritz Angermann
d6255c97aa
allow empty packages
fixes #50
2019-10-22 09:46:58 +08:00
Moritz Angermann
5884ab02be
Overlays (#261)
The Overlays branch

This is a major reorganization in how haskell.nix is used, and marks our 1.0 release.
The branch doesn't build due to numerous issues that we believe to be with the CI
and not this branch. We expect only very minor adjustments prior to calling this the
official 1.0 release.

* Move iohk-nix patches into haskell.nix

This moves the customizations we did in iohk-nix
into haskell.nix via overlays and config.

Add bootPkgs logic

this moves the nuking of bootPkgs where it belongs. This should eventually still be
removed and replaced by a proper solution, that doesn't require the nuking of
bootPkgs.

Allow us to bootstrap binary ghcs and a cabal-install

With this we can do the following:

```
$ nix repl compiler/old-ghc-nix
nix-repl> :b (let pkgs = import <nixpkgs> {}; in with import ./. {}; import ./compiler/bootstrap/cabal-install.nix { inherit (pkgs) fetchurl stdenv zlib; inherit hackage
; ghc = ghc844; src = pkgs.fetchurl { url = "https://github.com/haskell/cabal/archive/Cabal-v3.0.0.0-rc3.tar.gz"; sha256 = "1zl2mgg8307ykq3v8nmafc6zdhhj1cw7w8ffpap16dsm6
5lbnx33"; }; })
```

which wile it may look daunting, will allow us to bootstrap a
cabal-install with a ghc. From that point onwards, we should be able to
build any hackage package via haskell.nix.

Pass through cabal-install version

Better threading of arguments.

Add bootstrap overlay

Allow alex + happy to be built

This still has a wart: we need nix-tools, and for that we use the ghc865 from
nixpkgs. Ideally we'd build nix-tools against a specific ghc, but then
we'd need a build expression for that.

Make ghcjs work

Building something like this:
```
 nix build '(with import ./. { nixpkgs = ../nixpkgs; nixpkgsArgs = { crossSystem = { config = "js-unknown-ghcjs"; }; }; }; (haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2"; })).components.exes.hello'
```
will now work. Assuming `nixpkgs` has been appropriately patched to support the `js-unknown-ghcjs` triple.

Also: this will need an additional `Cabal` patch, to make `Cabal` understand what it needs to do with: `dist/build/hello/hello: copyFile: does not exist (No such file or directory)`

It needs to learn that `dist/build/hello/hello.jsexe` is what it wants to copy and that that is a directory.  Luckily we do have some code in Cabal already that does this for `.exe` on windows.

Build `js-unknown-ghcjs` packages with haskell.nix

Using the following expression:
```
with import ./. { nixpkgs = ../nixpkgs; nixpkgsArgs = { crossSystem = { config = "js-unknown-ghcjs"; }; }; };
let Cabal = buildPackages.haskell-nix.hackage-package {
    name = "Cabal"; version = "2.4.1.0";
    modules = [
        { packages.Cabal.patches = [ ./Cabal-install-folder.diff ]; }
    ];
}; in
(haskell-nix.hackage-package {
    name = "hello"; version = "1.0.0.2";
    modules = [
    	    ({config, ... }:{ packages.hello.package.setup-depends = [ Cabal ]; })
    ];}).components.exes.hello
```
in a `test.nix` file. And running
```
nix build -f ./test.nix
```
on it, will produce
```
./result
├── bin
│   └── hello.jsexe
│       ├── all.js
│       ├── all.js.externs
│       ├── index.html
│       ├── lib.js
│       ├── manifest.webapp
│       ├── out.frefs.js
│       ├── out.frefs.json
│       ├── out.js
│       ├── out.stats
│       ├── rts.js
│       └── runmain.js
└── share
    └── doc
        └── x86_64-linux-ghc-8.6.5
            └── hello-1.0.0.2
                └── LICENSE

6 directories, 12 files
```
2019-10-21 20:07:58 +08:00
Hamish Mackenzie
94f4679618 Add setup-depends to shellFor (#259)
* Add failing test for shellFor with setup-depends

* Add setup-depends to shellFor
2019-10-13 20:01:25 +08:00
Rodney Lorrimar
b47a6bb1a2 shellFor: Use CABAL_CONFIG only with exactDeps = true (#255)
* shellFor: Use CABAL_CONFIG only with exactDeps = true

* shells: Put write-ghc-environment-files: never in cabal.config
2019-10-13 19:43:17 +08:00
Hamish Mackenzie
147cf21341 Add ghcOptions on packages (#257)
* Add `ghcOptions` with example and docs
2019-10-13 14:19:59 +08:00
Hamish Mackenzie
fdcb2da2a8
Add default for shellFor packages (#242)
Uses the `isLocal` for property set by `plan-to-nix` and `stack-to-nix`
on packages where the source is referenced in the `cabal.project`
or `stack.yaml` file.
2019-10-01 11:10:11 +13:00
Hamish Mackenzie
f5b80ecf0e Fix issue with testWrapper (exposed by #238) (#243)
* Fix issue with testWrapper (exposed by #238)

We were relying on the `string` type's merge function quietly
concatenating strings.

Described here:
700cc56a0e/lib/types.nix (L218-L221)
2019-09-16 10:40:58 +08:00
Hamish Mackenzie
0366537651
Use new cleanSourceWith to filter component source (#209)
When trying to build haskell packages from local source using nix (
source code you have used `git clone` to retrieve and have modified)
it is often annoying that small changes can trigger a lot of components
to be built unnecessarily.  For instance if you change the code for
a test in a package it will often trigger builds of the library and
all its dependencies.

To avoid this problem we could manually set up `cleanSourceWith` calls
in nix to filter out files that are not need, but to do this every
component would be difficult and error prone.

This change automates this process using the information in the
packages `.cabal` file to filter the source of each component
automatically  when using `callCabalPlanToNix` (we should be able to
add it to `callStackToNix` too).

## How does it work?

* A new version on `cleanSourceWith` is used that adds a `subDir`
  argument.  It allows descending into a subdirectory to compose with
  cleaning the source.

* A new `--full` argument is passed to `plan-to-nix` by
  `callCabalPlanToNix` telling it to output extra information about
  the cabal packages in the plan (directories and filenames).

* `callCabalProjectToNix` uses the new `subDir` argument of
  `cleanSourceWith` when setting the packageSrc.

* `comp-builder.nix` and `setup-builder.nix` use a new
  `cleanCabalComponent` function to further clean the packageSrc
  using the new information in the `package` and `component`.

## hpack wildcards
`package.yaml` files can include wild cards and these are not handled
yet (they do not map to anything in the `.cabal` file and so are lost).
They will need to be added manually to the appropriate field
(eg. `packages.xyz.package.dataFiles`)

If your hpack file does not contain wildcards or if you are willing to
add the wildcards entries manually in nix it is still useful to
enable cleaning on hpack.

For example:

```
packages.ghc-toolkit.package.cleanHpack = true;
packages.ghc-toolkit.components.library.extraSrcFiles = [
  "genapply/**/**"
  "boot-libs/**/**"
  "ghc-libdir/**/**"
  ];
```
2019-08-26 12:27:47 +02:00
Yorick
7cbb5f50c1 Never build with more than -j4 because of slowdown (#227)
Same thing happens in nixpkgs. https://gitlab.haskell.org/ghc/ghc/issues/9221
2019-08-16 19:30:38 +02:00
Hamish Mackenzie
3ae2303b14
Add enableSeparateDataOutput like nixpkgs (#222) 2019-08-09 17:46:21 +12:00
Hamish Mackenzie
05c9b639e3 Use ghc -threaded when building custom setups (#215)
This is to match how cabal-install builds custom setup executables.
2019-07-28 20:39:15 +08:00
Moritz Angermann
8a3489e1dc
Better defaults (doExactConfig = true; non-reinstallable lib:ghc) (#206)
* Better defaults (doExactConfig = true; non-reinstallable lib:ghc)

Disabling haddocks by default has unintended consequences, as such we'll wait for the `.doc` derivation to solve this.

Fixes #201, #191
2019-07-16 15:14:57 +08:00
Rodney Lorrimar
f81a37eda4
Make sure hoogle is available in ghcWithHoogle (#196) 2019-07-16 10:17:49 +10:00
Hamish Mackenzie
efab350c0f Fix setup-depends dependencies (#124)
* Use setup-depends from nix-tools output

* Use `-package ghc` when building Setup.hs

* Include --package-db when building Setup

* Fix for tests on case insensitive FS (macOS)

The file `conduit.hs` looks like `Conduit.hs` to ghc and it uses it
by mistake for `import Conduit`.
2019-07-12 21:48:13 +08:00
Rodney Lorrimar
0663a9cd03
Add ghcWithPackages and ghcWithHoogle to hsPkgs (#150)
* Add ghcWithPackages and ghcWithHoogle to hsPkgs

* tests: Add ghcWithHoogle test

* Update changelog
2019-06-21 22:40:08 +10:00
Rodney Lorrimar
5ac12d01aa
builder: Install benchmarks properly (#175)
* builder: Install benchmarks properly

* builder: reduce duplication in test/benchmark installPhase
2019-06-21 12:21:58 +10:00
Rodney Lorrimar
c6038d4860 shellFor: Update don't overwrite passthru (#180) 2019-06-15 08:24:17 +02:00
Rupert Horlick
83e4c75957
Update comp-builder to run tests directly (#168) 2019-06-07 16:47:40 +01:00
Hamish Mackenzie
17c345fc74 gobject-introspction is not always available (#166) 2019-06-07 09:41:13 +08:00
Moritz Angermann
ea6f125ca4
Adds profiling support (#162)
* Adds profiling support

* Drop debug info
2019-06-04 11:28:14 +08:00
Hamish Mackenzie
e632534506 Fix for haskell-gi packages (#148)
* Fix for haskell-gi packages

* Add comment explaining the hacky gi-* workaround
2019-06-02 21:14:14 +08:00
Rupert Horlick
26c5b7be76 Add hooks to all components (#158) 2019-06-02 21:13:32 +08:00
Jean-Baptiste Giraudeau
3fb220334f
Fix name of shellFor derivation for a single package. (#155) 2019-05-30 22:46:39 +02:00
Rodney Lorrimar
c69cf9ed60
shellFor: Add the hoogle index 2019-05-28 10:53:05 +10:00
Rodney Lorrimar
a4479de7cd
Move builder flatDepends to haskellLib.flatLibDepends
This function is also useful for the hoogle index builder.
2019-05-28 10:53:04 +10:00
Rodney Lorrimar
bbd0133281
shellFor: Provide correct dependencies
Now the shell provides the dependencies of the given Haskell packages,
and not the packages themselves.

System libraries and Haskell executables are added to the shell.
2019-05-28 09:34:38 +10:00
Rodney Lorrimar
49eb3279e4
shellFor: provide CABAL_CONFIG in shell 2019-05-28 09:34:38 +10:00
Rodney Lorrimar
4ecc0aa041
Add config.hsPkgs.shellFor function
I needed to rearrange a few things to write this function.
2019-05-28 09:34:38 +10:00
Hamish Mackenzie
7b438d8d74 Add more pkgconf mappings (#126) 2019-05-17 15:59:05 +08:00
Edward Amsden
413d5c9dbd Add shellHook option to components (and packages and plans) (#117) 2019-05-17 10:55:04 +08:00
Hamish Mackenzie
0cc3670a24 Adds ghcjs and Asterius as cross compilers (#106)
This adds ghcjs and asterius cross compiler support to haskell.nix.  For proper ghcjs/asterius cross compiler you'll need to add them to nixpkgs.
2019-05-16 21:06:16 +08:00
Moritz Angermann
ff3b3162df Respect dontStrip 2019-05-13 14:10:18 +08:00
Rodney Lorrimar
b94ea34ecd Rename withPackage to ghcForComponent 2019-05-13 12:26:18 +08:00
Rodney Lorrimar
ae3ef84a8e Build without GHC environment files, instead using wrappers
Lets development shells work.
2019-05-13 12:26:18 +08:00
Moritz Angermann
2a2d2dd7b4
Fix unlit and other lib/bin tools for ghc 2019-05-10 23:23:04 +08:00
Moritz Angermann
373ac25398 --via-asm only on windows 2019-03-15 10:38:12 +08:00
Moritz Angermann
8ffa7cd939
Adds sublib support (#63) 2019-03-13 15:43:48 +08:00
Kirill Zaborsky
3c78fdaede Use hpack to generate cabal files when required (#82)
* Use hpack to generate cabal files when required
2019-03-06 08:46:34 +08:00
Jean-Baptiste Giraudeau
aec89ccf9c Disable haddock when cross-compiling. 2019-03-04 15:15:04 +08:00
Will Fancher
24b6d6ae0e Fix building all component 2019-02-20 16:17:44 +08:00
Will Fancher
bda8ae7319 Revert "builder: Remove self from depends of "all" component"
This reverts commit 0747270c9d.
2019-02-20 16:17:44 +08:00
Rodney Lorrimar
d1457606ed
builder: Add haddock and hoogle to components.library.doc 2019-02-12 12:44:10 +10:00
Rodney Lorrimar
0747270c9d builder: Remove self from depends of "all" component 2019-02-07 09:39:12 +08:00
Rodney Lorrimar
20226fa294
builder: Add nix-shell development environments 2019-01-30 15:38:38 +10:00
Rodney Lorrimar
73f3733a2f
Add an "all" component 2019-01-30 15:25:17 +10:00
Jean-Baptiste Giraudeau
c0cb0756df Fallback to LicenseRef-OtherLicense on unknown license. 2019-01-26 11:53:09 +08:00