Commit Graph

246 Commits

Author SHA1 Message Date
Moritz Angermann
a500f39da7
Musl changes (#700)
This should simplify the interaction with musl quite a but.
Musl specific mapping should go into the musl overlay now.
2020-06-23 09:45:22 +08:00
Moritz Angermann
74edd91659
backport ghc!3227 (#718)
This essentially backports the following two commits (make build system parts only)

- bec76733b8
- 67738db100

fixes #584
2020-06-22 08:03:57 +08:00
Hamish Mackenzie
21a6d6090a
compiler-nix-name fix for shellFor tools (#719)
Currently the ghc version is picked to match the `shellFor` project
and you cannot replace it by specifying `compiler-nix-name`.
This change fixes that and also uses `ghcOverride` so warning to asking
for a `compiler-nix-name` is not displayed when the compiler has already
been picked (by the project that shellFor is for).
2020-06-21 22:34:25 +12:00
Hamish Mackenzie
9e6820cc71
Add haskell-nix.project (and project') (#703)
Generalized version of the `cabalProject` and `stackProject`
functions.

Automatically selects the correct project type based on the
`projectFileName` argument if provided or what files exist in
the `src` directory if no `projectFileName` was specified.

If it cannot be determined which it should use the following
error message is given:

```
error: haskell-nix.project : both `stack.yaml` and `cabal.project` files exist set `projectFileName = "stack.yaml;"` or `projectFileName = "cabal.project";`
```
2020-06-19 20:07:19 +12:00
Hamish Mackenzie
e1589cc74b
Capture files generated by ghc for ghcjs/ghc-boot (#698) 2020-06-19 14:13:29 +12:00
Hamish Mackenzie
d7b6258c0d
Support tool "cabal-install" "3.2.0.0" (#704)
Currently only `tool "cabal" "3.2.0.0"` works.
2020-06-19 09:20:10 +08:00
Hamish Mackenzie
d98b1e3b6e
Add sha256map to cabalProject & stackProject (#697)
This is a simple way to specify the sha256 values for references
to git repositories that do not have a `--sha256:` comment in the
`cabal.project` file or a `# nix-sha256:` comment in the `stack.yaml`
file.

The tests demonstrate how to use `sha256map` with both
`cabalProject` and `stackProject` to build the
haskell-language-server from github with the sha256 hashes
needed to work with `--option restrict-eval true`.
2020-06-16 13:40:19 +12:00
Hamish Mackenzie
8cbf979538
Add nix-tools to niv and update docs to fix #675 (#678)
* Updates docs/user-guide.md

Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
2020-06-15 14:36:05 +12:00
Hamish Mackenzie
edc948e0e8
Update nixpkgs 20.03 (matches with iohk-nix) (#671)
* Use hydra-migration in check-hydra.nix

* mkdocs fix is now in nixpkgs 20.03 (so this drops our work around)

* Adds sanity checks for #660

* Add missing ${targetPrefix} to NIX_LDFLAGS

* Use eval system for callStackToNix.

* Improves pins.
2020-06-14 22:54:03 +12:00
Tony O
c7e6531d2c
Fix flake overlay attr (#684)
Fix flake overlay attr

Solves the following error:

while evaluating the attribute 'overlays.combined-eval-on-build' at /nix/store/0gg5rsi7nvwlk2ky1w595qyjgwpqj35g-source/flake.nix:11:5:
value is a function while a set was expected, at /nix/store/0gg5rsi7nvwlk2ky1w595qyjgwpqj35g-source/flake.nix:10:15
2020-06-14 18:30:30 +08:00
Hamish Mackenzie
a405a837d0
Add libsodium to runtime deps of remote-iserv (#685) 2020-06-14 18:07:36 +12:00
Hamish Mackenzie
dcadfa8ab4
Use suitable hackage state for index-state (#673)
Fixes #672 by using the first index-state that is > than desired
index state.  It also passes `--index-state` to `cabal v2-cconfigre`
to make sure it cabal uses only the packages in the hackage
file that are before the specified date.

Fixes #540 by returning the `index-state` used back out of
`cabalProject` in the same way `plan-nix` is returned.
2020-06-13 01:03:17 +12:00
Hamish Mackenzie
e2a3995826
dontRecurseIntoAttrs was only recently fixed (#666)
fc64cf65ab
2020-06-10 14:54:02 +12:00
Hamish Mackenzie
56e552505c
dontRecurseIntoAttrs to prevent infinite recursion (#665) 2020-06-10 14:19:51 +12:00
Moritz Angermann
54f6fbf607
fix ghc being picked from the wrong package set (#663) 2020-06-09 20:05:24 +08:00
Michael Peyton Jones
908a3114d8
Materialization: add scripts for fixing materialized files and shas, expose via passthru and errors (#653)
* Add script for fixing materialized files

This is useful in two ways:
- We reference it in the error message, so users can more easily
copy-paste the correct call, rather than several lines of commands.
- We add it to `passthru`, so users can reference it directly when they
know they need to update the files, without having to first run a build
and find it on stderr.

* Add script for calculating the sha

This is useful in two ways:
- It makes it easier for users to copy from the message.
- We add it to `passthru` so users can call it directly if they know
they need to update the sha, without having to run a build and copy it
from stderr.

* Refactor unchecked a bit

Put the positive logic first, use the materialized files by preference
if they're there.

* Allow the updater script to take an argument

* Use double brackets

* Fix a dependency

* Separate generating and updating scripts
2020-06-08 22:19:20 +12:00
Hamish Mackenzie
26b8c1c75f
Add project and package attrs to components (#657)
This is handy if you want to access `project.hsPkgs.shellFor` or
`project.plan-nix` (will help with #653).
2020-06-08 12:45:40 +12:00
Hamish Mackenzie
15fc6b3774
Add ghc 8.10.1 (#541)
* ghc 8.10
* Adds/Updates/Removes materialization files
* Disable one-shot-kqueue-on-macos patch on ghc-8.10
* Test ghc883 and ghc8101 but only with nix 20.03
* Various smaller fixes.

This should fix the infinite recursion issue with #654

Co-authored-by: Lennart Spitzner <hexagoxel@hexagoxel.de>
2020-06-07 11:05:44 +08:00
Hamish Mackenzie
80e0e61a81
Fix arm cross compilation with ghc 8.6.5 (#654) 2020-06-06 13:32:09 +12:00
Travis Whitaker
ed673956e8
Native aarch64 support (#620)
* native aarch64 support

Co-authored-by: Moritz Angermann <moritz.angermann@gmail.com>
2020-06-04 20:29:50 +08:00
Hamish Mackenzie
3356114206
Symlinks in materialized cause permissions err (#650) 2020-06-04 19:57:50 +08:00
Hamish Mackenzie
ff9a01e82e
Add missing pins and test ghc865 and ghc883 (#641)
Now that the defaultCompilerNixName is used to choose which GHC to use
for tools we need to update haskellNixRoots to make sure the common
tools wind up in the cache.

To do this we add the compilerNixName as a dimension in ci.nix.
This has the added bonus of ensuring the tests a run with the
supported versions of ghc (not just the default one).

haskellNixRoots is also updated to include the tools built with the
defaultCompilerNixName (in particular cabal-install was not pinned
and this was the likely cause of significant builds due to cache
misses).
2020-06-02 11:44:03 +12:00
Hamish Mackenzie
74915fa817
Add niv sources at haskell-nix.sources (#622) 2020-05-21 15:39:39 +12:00
Hamish Mackenzie
099d830db1
Update ghc 8.4.4 based tools to ghc 8.6.5 (#618)
Although the default ghc used by haskell.nix is ghc 8.6.5 many of
the tools used in haskell.nix are still built with the boot compiler
ghc 8.4.4.  These include

  * haskell-nix.cabal-install
  * haskell-nix.alex
  * haskell-nix.happy

This change updates those to ghc 8.6.5 and includes materializations
for the new versions.

When cabal-install is built it is careful to disable materialization
checks on the version of itself used during the build to avoid
infinite recursion.

There was a version of nix-tools built with the boot ghc which was
only used when `checkMaterialization = true`.  It was used for
the boot versions of alex, happy and hscolour.  These have been update
to use the default (ghc 8.6.5) version of nix-tools and
checkMaterialization is forced off when they are being used to build
ghc.  This means the materialization will only be checked for these
when they are built independently (they are included in the test set
via haskellNixRoots).

Three new arguments are added to `default.nix`:

* `defaultCompilerNixName` if not specified "ghc865" is used
* `checkMaterialization` makes it easier to switch on materialization checks
* `system` defaults to `builtins.currentSystem`

This change also moves the work needed for hydra eval to the eval
system using a new `evalPackages` feature.  This includes:

* Fetching from git with `fetchgit`
* Building scripts with `runCommand` and `writeTextFile`
* `git ls-files` in `cleanGit`
* running `cabal v2-configure`
* copying materialized files (we are not sure why this is necessary but
  if we do not `cp -r` the files nix will not load them on hydra)

Reduce size of `make-config-files.nix` strings by around 80%.
These are unlikely to be the cause of hydra eval time memory
issues in the GB range, but were still quite large (around 10MB for the
`cabal-simple` test case).

There was issue causing excessive builds of the `git` package when
cross compiling.  Gory details are a comment in `lib/defaults.nix`
but in short if you use `git` you need an extra `.buildPackages`
one is not enough because it depends on `gdb` and that will
be different in `buildPackages` compared to
`buildPackages.buildPackages`.

Adds missing materialization files for ghc 8.4.4 (only needed
when `checkMaterialization` is on because of other
materialiazations, but good to have).
2020-05-21 11:31:26 +12:00
Hamish Mackenzie
d345d4f1d0
Apply fix from #611 to nix-tools (#612) 2020-05-17 16:33:28 +12:00
Hamish Mackenzie
3f06d5d140
Fix cleanGit uncached git when cross compiling (#611)
It turns out `git` depends on `gdb` in a round about way:

```
 git -> openssh -> libfido2 -> systemd -> python libxml -> Cython -> gdb
```

Somewhere in that chain there should perhaps be a `buildPackages` so
that the `gdb` that is used is not the one for debugging code in
the `final` (but instead the one for debugging code in
`final.buildPackages`).

Using `final.buildPackages.git` causes two problems:

  * Multiple versions of `git` (and that dependency chain
    to `gdb` are needed when cross compiling).
  * When `gdb` does not exist for `js`, so when cross
    compiling with `ghcjs` `final.buildPackages.git` fails
    to build at all.
2020-05-17 15:44:57 +12:00
Hamish Mackenzie
788e198376
Add compiler-nix-name to cabalProject (#610)
* Add compiler-nix-name to cabalProject

Setting the compiler explicitly does not make it easy for cross
compilation to also choose the correct compiler when compiling
build tools for the build platform.  Also it is easy to pass the
wrong compiler type.  Specifying just the nix-name of the compiler
makes that less likely.

Co-authored-by: Moritz Angermann <moritz.angermann@gmail.com>
2020-05-16 21:48:48 +08:00
Hamish Mackenzie
57481872ce
Add emscripten overlay with fixes needed for ghcjs (#609)
The newer versions of ghcjs use emscripten to deal with .c code.
The version of emscripten that is available by default in nixpkgs
does not include the "upstream" version of emscripten.

This commit takes the existing emscripten from nixpkgs and adds
the "upstream" version.
2020-05-15 21:46:23 +12:00
Moritz Angermann
f330b2407e
Add MR2537-use-one-shot-kqueue-on-macos.patch (#604)
This adds the one-shot-kqueue-on-macos MR from gitlab.
2020-05-14 14:26:30 +08:00
Hamish Mackenzie
71f31cef4a
Fix evalDeps package ids with - in name (#585) 2020-05-11 23:58:42 +12:00
Alexander Kudryashov
2257791b1e
Fix nixpkgs version check in musl.nix (#594) 2020-05-11 10:41:22 +08:00
Le Tuan
49ecc0e4db
fix: consider relocatable data as writable (#570)
When declared as constant, read-only relocatable data are written to an unwriteable .rel.ro.data section. Being unwriteable, the gold linker doesn't put them inside the GNU_RELRO segment, but in a always read-only segment. Starting the relocation phase of such a built program then ends in a segmentation fault.

By declaring read-only relocatable data as writeable, they will be put inside a writeable .rel.ro.data section. The gold linker will then assume that those can be put inside the GNU_RELRO segment, that will only be writeable during the relocation phase.

The as assembler and ld linker will always consider the .rel.ro.data as writeable before relocation, and put the associated data in the GNU_RELRO.

Co-authored-by: Michivi <webmaster@michvi.com>
2020-05-09 07:04:50 +08:00
Alexander Kudryashov
de3f82a419
Add native musl support (#578)
* Add native musl support

- adds haskellLibl.isNaviveMusl and related fixes (previously it was
assumed that for musl we always use cross-compilation)
- fixed some issues for musl intoduced in nixpkgs 20.03 (ssh/fetchcvs
infinite recursion, busybox pkgsMusl.pkgsStatic chain, etc.)
- cross-compilation fixes for ghc (absolute path for ar, always pass
target to configure, libffi and gmp packages for target platform) -
this needs more testing

* Better explanation for targetPlatform.{libffi, gmp}

* Ghc configure script now respect AR env variable


Co-authored-by: Moritz Angermann <moritz.angermann@gmail.com>
2020-05-08 15:32:40 +08:00
Hamish Mackenzie
a2d97bd9ad
Flake (#589 and #567)
Allows haskell.nix to be used as a nix flake.

Authored-by: Alexander Bantyev <balsoft@balsoft.ru>
2020-05-07 11:16:38 +12:00
Hamish Mackenzie
49cc903753
Remove failing iserv build (#581)
Removes ghc 8.8.2 from haskellNixRoots as #573 broke the compilation
of iserv for windows cross compilation (but 8.8.3 is ok).
2020-05-04 12:48:49 +08:00
Maxim Koltsov
07031ee224
External hackages (#535)
* Add support for external Hackage repositories

Currently haskell.nix is not able to build Cabal projects that depend on
packages from private Hackage repositories, as it make only main Hackage
available to cabal. This is unfortunate.

This commit adds this functionality, by allowing the user to pass
`extra-hackages` and `extra-hackage-tarballs` to `mkPkgSet` and
`callCabalToNix` respectively, to add as much extra repositories as
needed.

This repositories are first made available to Cabal when calling
`v2-configure`, resulting in correct plans. Later they are combined with
global Hackage when building dependencies of the local packages.

* Use cabal.project.freeze if available

Currently callCabalProjectToNix does not copy `cabal.project.freeze`
from source directory, leading to different build plans when building
components with nix and when building project with `cabal new-build`
inside `nix-shell`.

This behavior is undesired, so this commits fixes it.

* Add tests for extra-hackages functionality

Co-authored-by: Moritz Angermann <moritz.angermann@gmail.com>
2020-05-02 18:16:34 +08:00
Moritz Angermann
a6ad1b1775
Profiled iserv for profiled builds (#574)
* Profiled iserv for profiled builds

When trying to build profiled builds, we might end up in a situation
where the library we load requires symbols from the profiled rts. In
those cases we rely on the profiled RTS linked against iserv.

Also ghc has the slightly annoying preference of adding the `-prof`
suffix to the provided iserv program, thus we need two iservs now.

* Update mingw_w64.nix

Only prof, not debug.
2020-05-02 10:53:36 +08:00
Hamish Mackenzie
49cbd34534
remove creation of relative links in package db (#569)
Changing from absolute links to relative links increases the length of
the parameters passed during linking by half. For things that have many
dependencies, this results in linking failing with an "argument list too
long" error.

Fixes #562

This change also updates the CI configuration files to help make
it easier for CI to cope with this sort of change.

Co-authored-by: Richard Wallace <richard.wallace@simspace.com>
2020-05-01 16:49:22 +12:00
Hamish Mackenzie
5ebce0eb3c
Make it easier to access executable components (#565)
This overlay helps accessing common executable components.
Typically we want to make these available in a nix-shell
created with shellFor.  In most cases the package name
will be the same as the executable, but we have a
`toolPackageName` mapping to help when it is not.

```
# To get a single tool:
haskell-nix.tool "cabal" "3.2.0.0"

# This does the same thing as:
(haskell-nix.hackage-package {
  name = "cabal-install"
  version = "3.2.0.0"
}).components.exes.cabal

# To get an attr set containing multiple tools:
haskell-nix.tools { cabal = "3.2.0.0"; hlint = "2.2.11"; }

# To add tools to a shell:
shellFor { tools = { cabal = "3.2.0.0"; hlint = "2.2.11"; }; }
```

When used in shellFor the tools will be compiled with the same version
of ghc used in the shell (the build ghc in the case of cross
compilation).

Instead of a version string we can use an attr set containing
arguments that will be passed to `cabalProject`.

For instance to specify the ghc used to compile. Use:

```
haskell-nix.tool "cabal" {
  version = "3.2.0.0";
  ghc = haskell-nix.compiler.ghc883;
}
```
2020-04-29 19:10:14 +12:00
Hamish Mackenzie
52401d7cb8
Fix quirks with overlays/hackage-default-args.nix (#564)
Adds a place for fixes to common problems that arise when using
`hackage-project` and `hackage-package`.
2020-04-29 13:20:20 +12:00
Michael Peyton Jones
701c83fb43
Update nixpkgs pins to include 20.03 (#557)
* Update nixpkgs pins to include 20.03, wobble

- Add 20.03
- Remove 19.03 (and old 18.09 file)
- Update 19.09 to latest
- Update github pin to 20.03
- Remove workarounds for 19.03

* Mark openssl as allowedInsecure

* Force python3 for mkdocs
2020-04-29 02:49:36 +12:00
Hamish Mackenzie
e4d75d61f1
Allow materialized only (#563)
This change allows for just the materialized argument to be passed
and removes the sha256 values for haskell.nix's own materialized
nix files.
2020-04-27 23:20:32 +12:00
Hamish Mackenzie
d1102d342c
Add pins and materialization for ghc-boot-packages and ghc-extra-packages (#546)
* Include `tests` in path for cross compiled tests

* Add ghc-boot-packages-nix to haskellNixRoots

* Fix naming warnings in tests sources

* Uses a single cleanGit call for all the tests

* Add memoize code for ghc-boot and ghc-extra pkgs

* Memoize ghc-boot and ghc-extra pkgs nix

* Fix release.nix being more strict than ci.nix by updating filterAttrsOnlyRecursive in ci-lib.nix

* Nicer errors when materialized path does not exist

* Updated materialization docs

* Add internalHackageIndexState to set the index-state used within haskell.nix
2020-04-20 13:27:52 +12:00
Robert Hensing
57b1cf002b
{cabal,stack}Project': Expose pkg-set (#531)
This will allow the caller to use the haskell.nix options somewhat
like a submodule.
2020-04-11 12:44:22 +12:00
Travis Whitaker
cc0787c785
Fix #515 (#517) 2020-03-26 14:10:56 +08:00
Travis Whitaker
3932281deb
Linux Cross Work-Around for GHC #15275 (#515) 2020-03-26 10:52:04 +08:00
Michael Peyton Jones
b6a8a97249
Get the hackage index tarball at runtime, not eval time (#512)
* Get the hackage index tarball at runtime, not eval time
* Get rid of special case for update-hackage

Fixes #507.
2020-03-25 20:26:31 +08:00
Hamish Mackenzie
578e7dde6f
Fix reinstallable ghc for ghc 8.8.3 (#502) 2020-03-20 11:12:03 +13:00
Hamish Mackenzie
9fbf93e3c7
Fix musl test configuring openssl as linux-x86_64 (#490)
See: https://github.com/NixOS/nixpkgs/pull/82708
2020-03-17 17:28:09 +13:00
Le Tuan
8099da8fe0
Fix cross-compilation for armv6l (#480)
This PR adds a patch for GHC 8.6.5 to properly remove the atomic primops fallbacks on ARM architectures. Those primops called some GCC legacy synchronization functions that were not loaded during TH, ending in failure within `remote-iserv`. It turns out that the condition `!defined(arm_HOST_ARCH)` was never `true`, as `arm_HOST_ARCH` was actually defined (on ARM architectures) in a dependency of the `Rts.h` file.

This patch works for my use case (GHC 8.6.5 for armv6l). I haven't done any test on the other GHC versions.

This PR also includes a patch to actually use the native `pkgconfig` during cross-compilation.

Fixes #441

Authored-by: Michivi <webmaster@michvi.com>
2020-03-11 23:04:57 +13:00
Hamish Mackenzie
642636b47b
Update nixpkgs pins (#477)
This change updates the pins for nixpkgs to the latest upstream nixpkgs-19.*-darwin branches. It also moves the remaining fixes from the haskell-nix/channels/nixpkgs-19.*-darwin branches into overlays in haskell.nix.
2020-03-10 14:53:40 +13:00
Rodney Lorrimar
0933c58908
Fix evaluation of haskellLib.collectComponents (#479) 2020-03-09 20:47:26 +10:00
iohk-bors[bot]
e6af103e8d
Merge #471
471: wineTestWrapper: export Windows Path based on nativeBuildInputs r=hamishmack a=jbgi

otherwise `build-tools` are not available when running tests under wine.

Co-authored-by: Jean-Baptiste Giraudeau <jean-baptiste.giraudeau@iohk.io>
2020-03-08 08:56:26 +00:00
Moritz Angermann
16aa936903
Update to wine 3.21 to support rust application (#472)
cf. https://bugs.winehq.org/show_bug.cgi?id=43878
2020-03-05 19:33:41 +08:00
Jean-Baptiste Giraudeau
4483301f63
wineTestWrapper: export Windows Path based on nativeBuildInputs 2020-03-05 00:06:58 +01:00
Hamish Mackenzie
775c8cf756
Fix cross compilation issues for musl and aarch64 (#322)
* Enables tests for Musl and AArch64 (also rasbery pi, but leaves them disabled for now) and includes many fixes for the tests that were broken.

* Makes Musl cross compiler more like native (including making `ghci` and `runghc` work)

* Updates selection of enableShared

* Works around missing configFiles attribute issue

* Use ghc-extra-packages and compiler.nix-name to pick the right extra packages

* Leaves out --cross-compile on hsc2hs for musl

* Fixes haddock and hoogle for musl and disables them for other cross compilers

* Adds ghc 8.8.3

* Static link components (except libraries and `all`) on musl

* Use qemu for the arm cross compile `testWrapper`

* Add isCrossHost and isCrossTarget functions

* Fixes profiling on AArch64

* Disable split sections when compiling for windows (fixes GHC 8.8 cross compile to windows)

* Disable hoogle in cross compiler shells for now
2020-03-04 16:07:01 +13:00
Alexander Bantyev
64a27464a7
Fix enableShared logic (#448) 2020-02-18 10:18:23 +08:00
Kirill Elagin
6a2fe9ae07
Actually do not patch .gitignore 2020-02-11 13:13:27 +08:00
Kirill Elagin
f754c5bf4e
Cleanup iserv patches (#439)
This commit cleans up iserv-related patches, especially for GHC 8.4, by
making sure they are exactly changes made upstream (only with merge
conflicts resolved).

Overall, there are three groups of patches now:

1. move-iserv is merely an upstream change that was merged between 8.4
   and 8.6. The previous patch was probably some development version,
   now it is the same as upstream.
2. iserv-autoconf was merged upstream between 8.6 and 8.8. The patch
   consists entirely of replacing version numbers with variables,
   therefore applying the same patch to 8.4 and 8.6 causes conflicts, so
   we have two versions of the same patch for simplicity. Additionally,
   the 8.6 is different from the upstream one in that it does not remove
   the .cabal files, see the commit description in the patch for details.
3. iserv-cleanup was merged between 8.8 and 8.10. It applies cleanly to
   8.8 and 8.6, however there is conflict in one line when applying it
   to 8.4. As a workaround, when applying this patch to 8.4 we first
   prepare the source to avoid the conflict, and then undo this change.
   This allows us to use the same main patch for 8.4 as for 8.6 and 8.8.

Also, in all patches changes to .gitignore were manually removed, as
this file does not exist in the Nix checkout of src and this causes
the patches to fail.
2020-02-11 09:32:53 +08: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
122bd81150
Add ghc 8.8.1 to the supported compilers (#342)
* Add ghc 8.8.1 to the supported compilers

The `overlays/ghc.nix` overrides were not applied to the `ghc` used
to by the `exactDeps` and `envDeps` `passthru` derivations.  This
resulted in each ghc building twice with only one of them being cached
by hydra.

This change fixes this by moving the exactDeps and envDeps for ghc
into sub directories of the output of the ghc derivation itself.

Co-authored-by: Hideaki KAWAI <kayhide@gmail.com>
2020-02-04 15:19:37 +08:00
Edward Amsden
563e18c3d5
Unbreak Aarch32 cross-compilation (#411)
* Use quick-cross for cross-compilation to avoid qemu crashes
* Bring over patches from my old fork of iohk-nix
* Expand Aarch32 patches to ghc-8.6.5
* Turn off shared builds when cross-compilging for linux ARM
* Update compiler/ghc/default.nix
2020-01-31 20:58:09 +08:00
Moritz Angermann
e68599bec9
19.09 compat (#403)
* fix SETUP being build properly by the build stdenv (nixpkgs#56555 made NIX_DONT_SET_RPATH less restrictive; which showed up in 19.09).

* 19.09 fixes

* Update wine.nix
2020-01-16 16:25:31 +08:00
Hamish Mackenzie
06ea6ab854
Update cleanSourceWith based on the latest nixpkgs (#401) 2020-01-15 13:56:18 +13:00
Hamish Mackenzie
8e52ad6f96
Automatically generate cache for stackage projects (#397)
You can add a `# nix-sha256` comment to stack.yaml if you
need it to work in restricted mode.
2020-01-15 10:34:14 +13:00
Rodney Lorrimar
d7d24fde4b
mkStackPkgSet: filter out $locals package (#393)
I found that if I added this to my stack.yaml:

    ghc-options:
      $locals: -ddump-to-file -ddump-hi

As specified in https://docs.haskellstack.org/en/stable/yaml_configuration/#ghc-options

Then my build would fail to evaluate with:

    error: The option `packages."\$locals".package.identifier.name' is used but not defined.

So to fix it, we filter out these special package globs in mkStackPkgSet.

This commit also adds a regression test for that configuration option.
2020-01-09 16:07:34 +10:00
Edward Amsden
a1432c1f49 Change LLVM versions for ghc-8.6 to LLVM 6 (#385)
The LLVM versions specified for the ghc-8.6 series compilers in overlays/bootstrap.nix was LLVM 5, but these compilers state on the download page that they require LLVM 6. This resulted in a warning about a wrong LLVM version for every module compiled with the LLVM backend (e,g, when cross-compiling.) This PR updates the LLVM versions for these compilers to LLVM 6.

Note: ghc-8.8.1 (and presumably future ghcs in the 8.8 series) requires LLVM 7. However it appears haskell.nix does not yet support ghc-8.8.1.
2020-01-07 19:12:32 +13:00
Hamish Mackenzie
43fdc4dafd
Fix restricted eval mode issue with mkCacheFile (#392)
If the .nix files listed in the cache are full paths pointing at the
store we get errors like this in restricted eval mode:

error: access to path '/nix/store/...-cabal-simple.nix' is forbidden
in restricted mode
2020-01-07 19:07:25 +13:00
Hideaki Kawai
0e66dbd17f
Patch gcc version fix on macOS 2019-12-21 10:48:03 -07:00
Hamish Mackenzie
852c5216f9
ghc.exactDeps/envDeps built with unpatched ghc (#369)
The `overlays/ghc.nix` overrides were not applied to the `ghc` used
to by the `exactDeps` and `envDeps` `passthru` derivations.  This
resulted in each ghc building twice with only one of them being cached
by hydra.

This change fixes this by moving the exactDeps and envDeps for ghc
into sub directories of the output of the ghc derivation itself.
2019-12-18 16:42:23 -07:00
Dennis Gosnell
b390b34e18 Fix error with specifying rev to builtins.fetchGit when creating cache. (#366) 2019-12-13 16:11:00 +08:00
Hamish Mackenzie
300fff437e
Move envDeps and exactDeps into lib and ghc (#360)
This change moves the work done to in `envDeps` and `exactDeps`
from `make-config-files.nix` into the library components and
the `ghc` compiler component (well `passthru` derivations on the
`ghc` component).

This greatly reduces the number of times `runCommand` is
used while nix is working out what to build.

This fixes a performance regression in #323 for builds where
little or no work needs to be done.  While maintaining the
performance improvement in #323 that resulted from reducing the
number of calls to `ghc-pkg` when significant work does need
to be done.
2019-12-13 14:44:01 +13:00
Hamish Mackenzie
f5d1f82952
Add support for materializing generated nix files (#356)
This change adds a `materialized` argument to the functions that
generate nix files with `plan-to-nix` and `stack-to-nix`.

* Provides `builtins.trace` messages with pointers on how to do so.

* Includes a `checkMaterialized` option that can be used
  to verify the materialized files.

* Documents how to script updates with `plan-nix` or `stack-nix`.

* Outputs warnings if materialized files are used without hash
  (or without an `index-state` for cabal projects).

* Provides materialized nix files for `alex`, `happy` and `hscolour`
2019-12-10 16:42:25 +13:00
Dennis Gosnell
7e996d5f96 Update mkCacheFile and mkCacheModule to take is-private argument to use builtins.fetchGit. (#348) 2019-12-10 10:21:50 +08:00
Hamish Mackenzie
a28e3625ec
Fix ranlib issue on macOS (#354)
Because we `meta.platforms` was not set in `nix-tools/default.nix` we
were not testing or caching `nix-tools` for macOS.  As a result
we missed that there was a need for the ranlib fix on `macOS`.

This enables hydra builds of nix-tools on all platforms and fixes
the resulting issue with `ranlib` in the `old-ghc-nix` version
of ghc 8.4.4.

Also enables hydra builds of the plan-nix to make sure dependencies
of plan-nix are cached for darwin. And fixes the default `nix-tools`
arg for `hackageTarball`.
2019-12-09 12:10:41 +13:00
Hamish Mackenzie
d722b45c04
Fix issue where ghc != compiler.ghc865 (#353)
The overrides in the `ghc.nix` overlay were only applied to
`compiler.ghc865` (not `ghc`).

The fact `ghc` was not the same as `compiler.ghc865` resulted in extra
builds of ghc and a lack of caching of `haskell-nix.ghc` (used as
the default compiler by `cabalProject`).
2019-12-08 13:49:45 +13:00
Moritz Angermann
f64ff16c50 Ensure enable-shared is false for windows and iOS (#349)
Also includes a fix for `haskell.nix.hackage-package` function
2019-12-08 13:17:51 +13:00
Alexander Bantyev
f91f9ec880 Add the ability to cache stack projects (#334) 2019-12-04 18:42:27 +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
Rodney Lorrimar
2e4b4ebbb3
cleanSourceHaskell: Add more filters (#314)
* cleanSourceHaskell: Add more filters

* cleanSourceHaskell: Add a "name" parameter, split away the filter

* cleanSourceHaskell: Make it compatible with nixpkgs-19.03

* Adjust usage of cleanSourceHaskell in nix-tools
2019-11-18 16:46:39 +10:00
Hamish Mackenzie
ef4b453f8d
Apply binutils fix to only macOS (#315) 2019-11-13 21:57:38 +13:00
Hamish Mackenzie
7d96b156c5
Check ghc used is haskell-nix.compiler one (#312)
It is easy to mistakenly pass in a `haskell.compiler.ghcXXX` compiler
instead of a `haskell-nix.compiler.ghcXXX` one.  This leads to subtle
bugs (for instance missing Cabal library patch).
2019-11-11 01:01:30 +13:00
Hamish Mackenzie
023863aeca
fix #269. Apply fix to mkStackPkgSet (#310)
First fix only fixed `haskell-nix.snapshot` by applying the fix also
to mkStackPkgSet stack.yaml based projects should work with lts 14
2019-11-09 17:01:04 +13:00
Hamish Mackenzie
f2fffb6dd3
Update haskell-nix.haskellPackages to lts-14.13 (#299) 2019-11-07 15:39:29 +13:00
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