Commit Graph

181 Commits

Author SHA1 Message Date
Hamish Mackenzie
f279cdef5f
Update the project modules and fix missing args param (#1144)
There are now 4 project modules used to check the arguments passed to the various project functions:

* `project-common.nix` - Arguments used by all the project functions
* `stack-project.nix` - Used by the `stackProject` and `stackProject'` functions
* `cabal-project.nix` - Used by the `cabalProject` and `cabalProject'` functions
* `project.nix` - Just the `projectFileName` argument that is used by `project` and `project'` functions to determine whether to call `stackProject` or `cabalProject` function.

This also includes the `rawProject.args` that was mistakenly left out of #1141 causing #1142 and improvements for the docs for the use of the `shell` argument in `flake.nix` files.
2021-06-20 18:00:22 +12:00
Hamish Mackenzie
c3841b4208
Add cross compilation and devShell to project.flake (#1141)
The default shell `devShell` works by adding a default `shell` to all projects.  You can pass the shell arguments to the project function using the new `shell` argument:

```
let myProject = haskell-nix.project {
  src = ./.;
  shell.tools = { cabal = {}; };
  shell.crossPlatforms = p: [ p.cross ];
};
```

This will include js-unknown-ghcjs-cabal in the `devShell`.

To add cross compiled outputs to the flake pass `crossPlatforms` to the `flake` function.

```
myProject.flake { crossPlatforms = p: [ p.cross ]; }
```

To cross compile a component include the platforms `config` string to the output name like this

```
nix build .#js-unknown-ghcjs:pkg-name:lib:pkg-name
```
2021-06-17 19:07:37 +12:00
Hamish Mackenzie
90184a79f9
Better error message when building missing ghcjs (#1140)
Currently if you try to build a ghcjs version that does not exist
haskell.nix falls back on the GHC version.  Once ghcjs is in the
ghc tree this will work, but for now we should have an error
message that is more descriptive than attempting and failing to
build ghc for a js target.

New error looks like this:

```
$ nix-build -A pkgs-unstable.pkgsCross.ghcjs.buildPackages.haskell-nix.compiler.ghc861
error: ghcjs 8.6.1 is no longer supported by haskell.nix. Consider using 8.6.5
```
2021-06-17 11:57:21 +12:00
Hamish Mackenzie
f899936d1f
Update internalHackageIndexState (#1139)
The use of `sources.HTTP` to work around issues building GHC 9.0.1 causes a mismatch between `flake` based and non
 `flake` based derivations.

The fixed version of HTTP is now in hackage so updating the internal hackage index state used haskell.nix removes the need for the HTTP source override.
2021-06-16 22:10:42 +12:00
Hamish Mackenzie
0f568cbdf4
Fix haskell-language-server and ghc 8.10.5 (#1138)
Needs:

8fee87eac9

Which cannot be uploaded to hackage yet because of:

https://gitlab.haskell.org/haskell/ghc-api-compat/-/issues/1
2021-06-16 00:37:57 +12:00
Hamish Mackenzie
a5b74bf002
niv update nixpkgs-unstable and add ghc 8.10.5 (#1121) 2021-06-15 19:50:45 +12:00
Moritz Angermann
dd31db0a0a
Add enough logic to make plugins work conceptually. (#1131) 2021-06-07 12:07:56 +12:00
Hamish Mackenzie
532e71470b
Bump internal-* to ghc 8.10.4 (from 8.8.4) (#1129)
Anyone using `hpack` and/or `stack` will have a dependency on `internal-nix-tools` (built with a fixed version of ghc).  This is fine if your `nixpkgs` is one of the ones we cache, but if not we may have to wait for an extra ghc to build.  When this happens it would be nice if it is at least building a more recent version (rather than an older one).
2021-06-02 14:40:24 +12:00
Hamish Mackenzie
986a800713
Try to fix qAddDependentFile for windows (#1116)
Co-authored-by: Moritz Angermann <moritz.angermann@gmail.com>
2021-05-22 06:54:19 +12:00
Hamish Mackenzie
74d51c1737
Patch th-utilities for windows cross compile (#1114) 2021-05-17 21:12:40 +12:00
Hamish Mackenzie
ae7be4559f
Fixes for windows cross compilation (#1103) 2021-05-03 19:14:19 +12:00
Hamish Mackenzie
5758f1c8b4
Fix windows cross compile issues with C++ code (#1100)
This fixes issues when using packages like `double-conversion` in TH code.
2021-04-30 09:33:21 +12:00
Hamish Mackenzie
04c5b1e566
Update unboxed tuple patch for ghc 8.10 (#1093) 2021-04-18 02:38:07 +12:00
Hamish Mackenzie
91adf5f97d
Add crossPlatforms arg to shellFor (#1089)
This makes it easier to get cross compilers for a project in a nix shell.
2021-04-16 17:50:10 +12:00
Hamish Mackenzie
4f449d37f5
Use nix module system to check project arguments (#1087)
* Use nix module system to check project arguments

This change uses the nix module system for the arguments to:

* `cabalProject'`
* `cabalProject`
* `stackProject'`
* `stackProject`

This will:

* Give an error when the name or type of an argument is incorrect
  (currently misnamed args are quietly ignored).

* Fixes a problem with `projectCross` not having a way to pass different args to `cabalProject`
  for different platforms. We can now use:
    `({pkgs, ...}: { cabalProjectLocal = if pkgs.stdenv.hostPlatform.isX then ... })`
2021-04-08 12:06:26 +12:00
Hamish Mackenzie
9ce7bf1e02
GHCJS 8.10 (#1082) 2021-03-29 22:36:47 +13:00
Hamish Mackenzie
a59be5c421
Add GHC 9.0.1 (#1032)
Also refactors the way tests are filtered to use `meta.disabled` where possible.
2021-03-28 21:03:20 +13:00
Richard Wallace
91292dda70
enable static builds of bzip2 when cross compiling for musl (#1081) 2021-03-26 14:19:01 +13:00
Hamish Mackenzie
1abbd1656d
Add GHC 8.10 Make markLiveObject thread-safe (#1076)
See https://github.com/input-output-hk/haskell.nix/issues/1062
2021-03-19 17:01:45 +13:00
Hamish Mackenzie
e5ab3910e7
Check ghc-pkg works before we trust its results (#1069) 2021-03-18 19:54:46 +13:00
Hamish Mackenzie
4d700cf155
Fixing emcc usage in haskell.nix ghcjs (#1064)
* Use emscripten branch of GHCJS for 8.6

* Adds release-linux-only.nix (for hydra with no mac builders)

* Sets HOME to a temp dir once per derivation to help performance of emcc

* Updates materialization

* Uses symlinks to reduce ghc derivation size for wrapped ghcjs

* Removes compiler-nix-name test
    This test checked that the default compiler was overridden by the
    compiler-nix-name arg.  There is no default any more.

The GHCJS branches used include fixes for:

* hs$ret_1 typo (should be hs$ret1)

* A bignum issue
2021-03-12 12:21:07 +13:00
Hamish Mackenzie
fd07667307
Remove remaining hls hackage workaround (#1070)
This is now fixed in hackage (see https://github.com/haskell/haskell-language-server/issues/1525)
2021-03-10 18:49:23 +13:00
Hamish Mackenzie
ec23c34c81
Remove workarounds for HLS hackage issues (#1068)
These constraints have all been added to HLS 0.9.0.0 hackage and having them here also breaks HLS 1.0.0.0
2021-03-09 12:00:24 +13:00
Hamish Mackenzie
5c25ce919f
Add getComponent to project and package (#1060)
* Delays cabal configure errors until after evaluation when possible.

* Avoids rerunning long `cabal configure` if we already know it will fail.

* Provides a way to get a component from a package or project using a `cabal` like reference.

Code using the `tool` functions will automatically use `getComponent`.

For `(hackage-package {...}).components.library` is also ok.

```
# Consider changing hackage-package use:
(pkgs.haskell-nix.hackage-package {...}).components.exes.something
(pkgs.haskell-nix.hackage-package {...}).getComponent "exe:something"

# For any cabal project:
project.hsPkgs.somepackage.components.exes.something
project.getComponent "somepackage:exe:something"
# or do it in two steps
(project.getPackage "somepackage").getComponent "exe:something"
```

The reason for the new function is that we cannot provide the attribute interface without knowing that packages are in the project first.

Here is how the `cabal configure` error output is handled:

* The `plan-nix` derivation builds even if `cabal configure` fails.

* When it fails, it copies `failed-cabal-configure.nix` to the `$out/default.nix` along with a copy of the `cabal configure` output.

* When `failed-cabal-configure.nix` is imported and used in any way it writes the `cabal configure` output with `__trace` so it will always be visible.

* Instead of a `plan` the imported nix contains a `configurationError` pointing the `cabal configure` output.

* The intermediate functions `configurationError` and bubble it up to where it is needed.

* `getPackage` returns a mostly empty proxy for a real package when there is a `configurationError`

* The `getComponent` function always returns a derivation, but the version in the proxy writes the `cabal configure` output to stdout and calls `exit 1` (so that it will never build).
2021-03-04 20:10:58 +13:00
Hamish Mackenzie
43cb0fc895
Fix for Haskell Language Server from hackage (#1061) 2021-03-03 17:46:32 +13:00
Hamish Mackenzie
0d781c04c4
Switch from cabal 3.2 to 3.4 (#1058) 2021-03-01 15:42:23 +13:00
Hamish Mackenzie
583acc2219
Fix for postgresql-libpg and musl (fixes #948) (#1056)
This combined with setting the `use-pkg-config` flag on `postgresql-libpq` should get it compiling.  There is still a problem with `openssl` that requires a `module` to fix the linking of executables.

Add the following to the `cabal.project` file or to `cabalProjectLocal`:

```
package postgresql-libpq
  flags: +use-pkg-config
```

Include a module like this one to include `openssl` in the linker arguments:

```nix
{
  modules = [(
   {pkgs, ...}: final.lib.mkIf pkgs.stdenv.hostPlatform.isMusl {
     # The order of -lssl and -lcrypto is important here
     packages.postgrest.configureFlags = [
       "--ghc-option=-optl=-lssl"
       "--ghc-option=-optl=-lcrypto"
       "--ghc-option=-optl=-L${pkgs.openssl.out}/lib"
     ];
  })];
}
```

This PR also adds a "hackage quirk" for `postgrest`  to that makes these changes for `postgrest` automatically when built it as a `tool` or with `hackage-package`.

Unfortunately we do not have a good way to avoid the need make these changes.
2021-02-24 22:49:31 +13:00
Hamish Mackenzie
172d402394
Add more flakes support and getting started guide (#972)
This PR adds a `flake` function to haskell.nix projects.  It can
be used to transform the outputs of project into a flattened structure
that can be used to make a `flake.nix` file for your project.

Because the nix code and commands used are different a lot of stuff in
the getting-started.md will not work with a `flake.nix`.  So instead
of trying to add a flake section to that guide this PR adds a new
version for Nix Flake users.
2021-02-22 20:42:33 +13:00
Hamish Mackenzie
bab2eaea62
Enable debug info on linux targets (#1050)
* Add `.debug` to build any component with DWARF dugug info on linux
  (ghc >=8.10.2).
* Pass `enableDWARF` to `shellFor` for to get a shell where all the
  components are the `.debug` ones.
2021-02-22 18:27:36 +13:00
Hamish Mackenzie
42b10678ff
Add support for setting ghcOptions on all packages (#1046)
`ghcOptions` has been moved from package and is now a list of strings.
    old: packages.x.package.ghcOptions = "someGHCoption";
    new: packages.x.ghcOptions = ["someGHCoption"];
To specify ghcOptions for all packages:
    ghcOptions = ["someGHCoption"];
For a single component:
    packages.x.compoents.library.ghcOptions = ["someGHCoption"];
2021-02-19 00:38:36 +13:00
Hamish Mackenzie
cb95d533b8
Pin hls-plugin-api to fix hls tests (#1048) 2021-02-18 23:10:29 +13:00
Hamish Mackenzie
5d3975e338
Disable benchmarks and tests for tools (#1044)
By default haskell.nix cabalProject functions run cabal
configure with --enable-tests and --enable-benchmarks.
This is good when you are working on a project as
it means your tests and benchmarks are in the
package `components`.

The `tools` functions (and `shellFor` `tools` arg)
return `components.exes.${toolName}` and while
it is possible to access the other components
via the `project` and `package` properties of
tool component.

In some cases the benchmarks and tests can
have problematic constraints that cause
problems building other components.

Disabling the tests and benchmarks by default
when building `tools` should reduce the these
issues.
2021-02-17 01:27:23 +13:00
Hamish Mackenzie
413adb037f
Update core interface files GHC to 8.10.4 (#1039) 2021-02-16 23:15:55 +13:00
Hamish Mackenzie
fe68b7ec2b
Work around hls hackage constraint issue (#1043) 2021-02-16 22:14:56 +13:00
Hamish Mackenzie
422c4afec3
Update unboxed tuple patch (#1037)
Also Includes aarch64 fix in ghc 8.10.4

See https://github.com/input-output-hk/haskell.nix/issues/1027
2021-02-12 23:06:08 +13:00
Hamish Mackenzie
f056dd34cd
Fix the way ExeDependency is handled (#1036)
See https://github.com/input-output-hk/nix-tools/pull/101

We should look up hsPkgs.${pkg-name}.components.exe.${component-name}
instead of including the package as a dependency.

Adding `hsPkgs.${pkg-name}` a tool it is not clear which executable in the package `haskell.nix` should choose.

Haskell.nix did not deal with this well and in fact it could lead to `nix-shell` crashing.  For instance using `shellFor` to make a shell for building `haskell-language-server` with `cabal build` crashed as a dependency on `ghcide` the executable (by the `ghcide-bench` executable) caused infinite recursion.  Allowing `ghcide-bench` to correctly depend just on `components.exes.ghcide` fixes this.

This PR also includes:

* Updated materialized files built with the new nix-tools and latest index-state
* Small update to GHCJS (pins happy) to fix issue that showed up when the materialization was updated
* A fix for the infinite recursion issue when updating materialized files (by adding ghc-boot-packages-unchecked).
* Performance fix for shellFor (checks just the names of component derivations when filtering).
2021-02-12 10:45:23 +13:00
Hamish Mackenzie
89f50a96dd
Use pkgs.lib instead of stdenv.lib (#1031)
Fixes:

Warning: `stdenv.lib` is deprecated and will be removed in the next release. Please use `pkgs.lib` instead. For more information see https://github.com/NixOS/nixpkgs/issues/108938
2021-02-11 01:07:16 +13:00
Hamish Mackenzie
1498e70fcb
Pin index-state used for hls until latest hackage works (#1035) 2021-02-10 17:27:23 +13:00
Hamish Mackenzie
cd91692380
GHC 8.10.4 (#1033)
* Adds GHC 8.10.4 support

* Drops GHC 8.8.3, 8.10.2 and 8.10.3 from CI

* Adds warning to encourage people to use less buggy ghc
2021-02-09 14:30:32 +13:00
Hamish Mackenzie
43513e406c
Use hackage version of haskell-language-server (#1015)
Also removes the custom-tools as haskell-language-server is now in
hackage!

Removes the custom-tools as haskell-language-server is now in
hackage!

We considered also adding support for -wrapper, but decided it was better to fix emacs so that it works if just haskell-language-server is present.
2021-02-09 01:58:36 +13:00
Hamish Mackenzie
40a26afa33
Patch for ghc 8.10.3 to make musl builds possible on aarch64 (#1029)
See https://github.com/input-output-hk/haskell.nix/issues/1027#issuecomment-772087166
2021-02-04 01:55:16 +13:00
Hamish Mackenzie
64efc98852
Support githash package and cross package refs (#843)
* Adds support for cross package refs (with a project).  Relative
  directory references between packages within a project should now
  work.
* Adds `includeSiblings` to `cleanSourceWith`.  When `true` it
  prevents the `subDir` arg from causing filtering of other directories.
* Adds `keepGitDir` to `cleanGit` to allow `.git` directory to be kept
  (useful for components that use the `githash` package).
2021-01-14 12:34:06 +13:00
Hamish Mackenzie
0f7c5afc41
Add ghc 8.10.3 (#980) 2021-01-11 18:47:56 +13:00
Hamish Mackenzie
2b7d93baf6
Allow package-name:sublib-name in build-depends (#963)
With cabal 3 it should be possible to reference a sublib in the
`build-depends` of a `.cabal` file using `package-name:sublib-name`

The `cabal-sublib` test is updated to include the new type syntax
and a fix is included for the component builder.

We will need to update `plan-to-nix` in `nix-tools` as well.
For now the work around is to use a module to add the sublib to
`depends` (see `test/cabal-sublib/default.nix`).

Without this fix the `cabal-sublib:slib` was not found by
`setup configure` because only `--dependency=slib=cabal-sublib-...`
was passed.  The fix is to also pass
`--dependency=cabal-sublib:slib=cabal-sublib-...`.
2021-01-08 23:11:16 +13:00
Jonas Carpay
9047c0f449
Add haskell-language-server 0.8.0 (#989) 2021-01-05 10:21:25 +00:00
Hamish Mackenzie
dcecae2365
Improve conditional guarding gi fix (#977) 2020-12-18 19:23:12 +13:00
Michael Peyton Jones
738af22ce9
Move more CI to 20.09 (attempt 2) (#975)
* Update default nixpkgs to 20.09

* Move more CI to work on 20.09 by default

* IFD level 1

* Use nixpkgs 20.03 emscripten (needed for ghcjs)

* Add missing materialized files

* Add missing materialized files

* Fix for ghc 8.8 build on darwin

* Fix for ghcjs 8.8 build on darwin

* Fix hls stack test eval for ghc810220201118

* ifdLevel 2

* Oops: accidentally turned on tests for experimental GHC

* Revert "Fix hls stack test eval for ghc810220201118"

This reverts commit b405cd7ee8bd62214bd2d0a61e0317673b5bf1b5.

* ifdLevel 3

* Disable GHC 8.6.5 windows cross on nixpkgs 20.09

* Update supported GHC doc with a table

* Add emscripten comment

Co-authored-by: Hamish Mackenzie <Hamish.Mackenzie@iohk.io>
2020-12-17 15:57:09 +00:00
Drew Hess
c9dde4d9f4
x509-system: use /usr/bin/security on macOS. (#974)
This mirrors the workaround in nixpkgs for haskellPackages.

ref: https://github.com/NixOS/nixpkgs/pull/47676
2020-12-16 16:00:20 +00:00
Michael Peyton Jones
1ad1cdc050
Add internal- variants of cabal-install and nix-tools to roots (#968)
Not caching these makes it easy to have an uncached dependency on GHC
8.8.4 (which is the compiler used to build them).

Fixes #967.
2020-12-15 19:30:22 +13:00
Samuel Evans-Powell
4c42100df0
Coverage: allow projects with no libraries (#962)
* Coverage: allow projects with no libraries

- Prevent projects without a library from breaking the coverage report
  generators.
- Added a test to ensure projects without libraries can build coverage
  reports.

* Ensure the correct GHC version is used in project coverage reports

- Previously, when trying to determine the version of GHC to use for a
project coverage report, we would attempt to find the version of GHC
used in the constituent coverage reports, or default to the GHC that
is shipped with Nixpkgs. Using the GHC that ships with Nixpkgs is
problematic (specifically the coverage-no-libs tests fail to run on
Hydra), so we now ask the user to pass in the project to the
"projectCoverageReport" function so we can find the correct version of
GHC to use in a foolproof manner.
2020-12-10 20:47:57 +13:00