Commit Graph

211 Commits

Author SHA1 Message Date
Hamish Mackenzie
22e8da5810
Fix #269 by not looking for libiserv in hackage (#297)
Also fixes packages like that depend on the `ghc` library.
2019-11-06 14:33:48 +13:00
Hamish Mackenzie
63fc8bec4c
Add stack-nix to stackProject (#293)
Like `plan-nix` for `cabalProject` this gives us a way to inspect the
nix files generated by `stack-to-nix`.  It may also adds `stackProject'`
that like `cabalProject'` allows us to get `stack-nix` independently of
hsPkgs (to avoid unwanted evaluation).  This can be useful for caching
and preventing GC of evaluation time dependencies of the project.
2019-11-05 19:36:48 +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
4d27798d6d
Use fixed output derivations for bootstrap plans (#286)
Currently when a dependency of cabal-install or plan-to-nix changes
the cabal new-configure and plan-to-nix have to be rebuilt in order
to recalculate the plan-nix for bootstrap packages alex, happy and
hscolour.  We have pinned the inputs such as hackage index-state
so that the plan generated should be the same.  Unfortunately it can
still result in a long wait.

Haskell.nix does cache the result via haskellNixRoots when built on
iohk's hydra server.  But if you use a different version of nixpkgs
it is unlikely to work.  If you have access to a CI that populates a
nix cache you can add haskellNixRoots to your CI build, but if not
you are kind of stuck.

One option to help with this would be to include the plan-to-nix output
in the haskell.nix git repository.  But intermediate files in git is
not nice.

Instead this PR adds just the hashes of the output to the derivations
that runs plan-to-nix.  Since the inputs are fixed or should have
no affect on the result (GCC version for instance), we should
be able to rely on them remaining constant.
2019-11-02 01:21:30 +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
1a28ea9ca4
Add haskellNixRoots and withInputs to help caching (#271)
Now that haskell.nix relies on IFD internally it is helpful to have
the nativeBuildInputs of the IFDs built and cached.
2019-10-28 17:28:56 +13:00
Hamish Mackenzie
f2c2520115 Expose plan-nix for alex, happy and hscolour (#267)
This exposes the plan nix though:
bootstrap.haskell.packages.alex-project.plan-nix

By building this on hydra you can get better errors and I think it
helps ensure cache stays populated with the dependencies needed to
build the plan.

It is also handy to be able to inspect the nix files that are
generated by plan-to-nix.
2019-10-23 15:49:49 +08:00
Hamish Mackenzie
39739d9d8c Reorg cardano/plutus examples. Move mkCacheModule (#265)
* Reorg cardano/plutus examples. Move mkCacheModule

Moves the example code from `ci.nix` into `examples/`.  Also moves
`mkCacheModule` into `overlays/haskell.nix` and calls it from
stackProject.
2019-10-23 09:46:24 +08: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
Hamish Mackenzie
3984c0e2a6 Pin the index-state used by ghc dependencies (#264)
* Pin the index-state used by ghc dependencies

Currently when a new hackage index-state is available (every day on
haskell.nix/master branch) the index-state used alex, happy and hscolour
is in the bootPkgs is updates to that latest one.  This results in a
rebuild of GHC (even though the build plans are likely unchanged).

By pinning the index state for these bootPkgs nix will be able to
reuse GHC.  The only down side is that if we need to get new versions
of alex, happy and hscolour into bootPkgs we will likely need to bump
the index-state attributes as well as the version.
2019-10-22 17:14:08 +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