Commit Graph

70 Commits

Author SHA1 Message Date
Silvan Mosberger
af5998fe8d
Include terminfo in nonReinstallablePkgs for reinstallableLibGhc (#606)
This allows building at least haddock-api, which depends on the ghc
library, with reinstallableLibGhc = true.
2020-05-15 19:02:41 +08:00
Hamish Mackenzie
caf4e3064b
Fix for errorHandler argument missing issue (#595) 2020-05-11 12:15:05 +08:00
Moritz Angermann
9ff04e5267
Update plan.nix 2020-05-09 11:30:12 +08:00
Jean-Baptiste Giraudeau
d47ae23df0
Externalize error msg functions (#588)
* move error messages functions from hackage.nix to haskell.nix

Co-authored-by: Moritz Angermann <moritz.angermann@gmail.com>
2020-05-09 11:08:45 +08:00
Jean-Baptiste Giraudeau
78f4e25f5c
Use "default" as default profilingDetail (#532)
so that toplevel-functions is used for executables by default.
2020-05-02 11:27:08 +08:00
Yorick
b921ff83f0
fix profilingDetail errors when enabling profiling (#493) 2020-03-17 18:45:56 +13:00
Moritz Angermann
f5b150c98a
build ghcjs (#382)
Adds `ghcjs` to haskell.nix

Co-authored-by: Hamish Mackenzie <Hamish.K.Mackenzie@googlemail.com>
Co-authored-by: Michael Bishop <cleverca22@gmail.com>
2020-02-09 20:03:22 +08:00
Hamish Mackenzie
41b72e182a
Keep source for component builds (#345)
This fixes and issue with TH functions like `makeRelativeToProject`
that can be used to keep a reference to source files.  If they are in
a temporary location that can result in surprising `file not found`
errors at run time.

It may also be useful for making debug symbols and the like refer to
real files.

There is a risk that keeping the source for all packages could expand
closure sizes (if for instance debug info is wanted, but you do not
want to keep the source in the store).  For that reason we have
made this an option that must be enabled.
2019-12-13 16:43:27 +13:00
Richard Wallace
1de76b7b1a More component configuration options (#336)
* allow patchelf, stripping binaries, static building, dead code eliminiation, and other doc flags to be controlled via component options

* add ability to turn off shared libraries
2019-12-04 10:21:30 +08:00
Hamish Mackenzie
a9b01221dd
Replace collectRunComponents with haskellLib.check (#316)
This change replaces `passthru.run` and `collectRunComponents` with
`haskellLib.check` and `$pkg.checks`.

Uses `ln -s` instead of `cp` for DLLs to avoid duplicating them.

Adds features to help debugging eval issues with haskell.nix/release.nix.
The ifdInputLevel can be set to limit the jobs included to control
how much work is done at the eval stage when looking for issues.

Reduce CI times by excluding older ghc versions from haskellNixRoots
(GHC 8.6.3 and 8.6.4)

Sets `preferLocalBuild=false` on `callCabalProjectToNix` and `callStackToNix`
to ensure they are cached on hydra for both Linux and macOS.

Fix `data-dir:` when cleaning components.
`normalizeRelativeDir` adds a slash on to the end of `dataDir`.
Adding another one here results in `//` and files are left out by
mistake.
2019-11-29 23:28:47 +13:00
Hamish Mackenzie
79c2c631c3
Run the cross compiled tests on wine (#317)
Changes to the haskell.nix code to fix broken tests:

* Add missing `then` to `call-cabal-project-to-nix.nix`.

* Fix default `hsSourceDirs` so that `.` gets included for `.all` component if one of the components does not have a `hsSourceDir` set.

* Fix `haskellNixRoots` so it works when cross compiling to windows.

Improvements to the haskell.nix tests:

* Run haskell.nix tests of nixpkgs 19.03 and 19.09.

* Run haskell.nix tests cross compiled to Windows under Wine (when possible).

* Add nix used as IFD inputs as tests to ensure they are cached.

* Use `haskell-nix.cabal-install` instead of `nixpkgs.cabal-install` in tests.
2019-11-20 13:47:15 +13:00
Hamish Mackenzie
be5ce45b31
Exclude pre/postCheck from all used by shellFor (#306)
Without this fix `shellFor` fails for packages where a component has
a `preCheck` or `postCheck` option set.  It should be safe to exclude
these because `shellFor` uses `phases = ["installPhase"]` and it seems
like a bad idea to use `all` for running tests (better to run the
individual `tests` components).
2019-11-08 21:01:47 +13:00
Hamish Mackenzie
612e983daa
Move all of haskell.nix into haskell-nix (#289)
Currently the haskell.nix overlays replace `haskell` and
`haskellPackages` in the root of pkgs with versions that have just a
fraction of what nixpkgs provides.
Although `haskell-nix.haskellPackages` could be used to provide a much
more complete set there are subtle differences that are likely to cause
issues (and nixpkgs has patches for many haskell packages).

To make it possible for haskell.nix and nixpkgs haskell to coexist,
we need to move the remaining parts of haskell.nix outside of the
`haskell-nix` attribute into `haskell-nix`.

```
  ghc                        -> haskell-nix.ghc
  cabal-install              -> haskell-nix.cabal-install
  haskell.compiler           -> haskell-nix.compiler
  haskell.packages           -> haskell-nix.packages
  bootstrap.haskell.compiler -> haskell-nix.bootstrap.compiler
  bootstrap.haskell.packages -> haskell-nix.bootstrap.packages
```

The following `haskellPackages` have been removed and instead the
nixpkgs versions will now be in `haskellPackages`.  User code should
be updated if the nixpkgs versions are not desired:

```
  haskellPackages.hoogle
    -> haskell-nix.haskellPackages.hoogle.components.exes.hoogle
  haskellPackages.happy
    -> haskell-nix.haskellPackages.happy.components.exes.happy
  haskellPackages.alex
    -> haskell-nix.haskellPackages.alex.components.exes.alex;
```

Guard code has been added to overlays/defaults.nix to prevent us
inadvertently depending on the nixpkgs `haskell` or `haskellPackages`
inside the haskell.nix code base.
2019-11-05 12:50:50 +13: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
Viktor Kronvall
5bb6704833 Make reinstallable if reinstallableLibGhc (#279)
This reverts the reinstallable packages to before PR #261 was merged and
only flags the additional non-reinstallable packages as
non-reinstallable if reinstallableLibGhc is `false`.
2019-10-29 11:14:18 +13: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
Moritz Angermann
623032c1af
Fix dealing with str (#263)
our change from string -> str to evade the warnings nix generates, resulted in a bunch of
unforseen consequences.

We now modify the str type a bit for our own use.
2019-10-14 16:00:39 +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
6f566a6d5d Filter components using buildable flag (#240)
* Filter components using buildable flag

* Bump nix-tools

* Include components without buildable flag

* Test buildable components are filtered correctly
2019-09-26 13:47:03 +08: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
Matthew Ess
fe44ce2300 types.string -> types.str (#238)
`types.string` is deprecated and now emits a warning on recent versions of nixpkgs. 

fixes #237
2019-09-10 13:31:59 +08:00
Domen Kožar
2de3c508af add ghc-boot to nonreinstallable pkgs (#233) 2019-09-07 20:35:44 +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
Hamish Mackenzie
3ae2303b14
Add enableSeparateDataOutput like nixpkgs (#222) 2019-08-09 17:46:21 +12: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
Michael Peyton Jones
9d251db79a Add custom errors for some missing attributes (#194)
* Add a custom error message for a missing stack resolver

* Make mkCabalProjectPkgSet robust to missing Hackage patches

* Add error for component prefix lookup

* Add a custom error for a missing GHC
2019-07-04 10:09:02 +10: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
Rupert Horlick
83e4c75957
Update comp-builder to run tests directly (#168) 2019-06-07 16:47:40 +01:00
Moritz Angermann
ea6f125ca4
Adds profiling support (#162)
* Adds profiling support

* Drop debug info
2019-06-04 11:28:14 +08:00
Rupert Horlick
26c5b7be76 Add hooks to all components (#158) 2019-06-02 21:13:32 +08: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
Moritz Angermann
4bc838cc86
Unbreak build-tools (#136) 2019-05-20 18:09:28 +08:00
Hamish Mackenzie
7b438d8d74 Add more pkgconf mappings (#126) 2019-05-17 15:59:05 +08:00
Moritz Angermann
072debc663 Fixup tests 2019-05-17 13:02:40 +08:00
Edward Amsden
413d5c9dbd Add shellHook option to components (and packages and plans) (#117) 2019-05-17 10:55:04 +08:00
Rodney Lorrimar
b94ea34ecd Rename withPackage to ghcForComponent 2019-05-13 12:26:18 +08:00
Moritz Angermann
0de60e8b0c
reinstallable lib:ghc and option inheritance (#88)
- reinstallable lib:ghc
- adds global options and option inheritance.
2019-03-18 21:20:33 +08:00
Moritz Angermann
696f22d87f Support library-less cabal files. 2019-03-15 10:39:01 +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
Will Fancher
de6a254d0f Remove self from depends of "all" component in the module system
Much cleaner to do this in the definition of `all`, rather than adding
special logic elsewhere.
2019-02-20 16:17:44 +08:00
Rodney Lorrimar
3584345a9a Fix cross build of withPackage wrapper 2019-02-14 09:35:57 +08:00
Rodney Lorrimar
d1457606ed
builder: Add haddock and hoogle to components.library.doc 2019-02-12 12:44:10 +10:00
Will Fancher
70f01c2029 Use mkForce in with-package test, and add a comment about the quirk. 2019-02-04 16:23:29 +08:00
Will Fancher
17ead947b0 Use config to set componentType defaults. 2019-02-04 16:23:29 +08:00
Will Fancher
a7568a0e77 Use mkmerge for the all component. [Fixes #42] 2019-02-04 16:23:29 +08:00
Rodney Lorrimar
57049091b3
Fix dependency merging of "all" component 2019-01-31 13:17:45 +10:00
Rodney Lorrimar
20226fa294
builder: Add nix-shell development environments 2019-01-30 15:38:38 +10:00