Commit Graph

141 Commits

Author SHA1 Message Date
Hamish Mackenzie a070082964 Improve flake code (#1743)
* Add hydraJobs.devShell and flatten hydraJobs

Also moves the `rawFlake` code into a `haskellLib.mkFlake` function

* Unflatten hydraJobs and add ciJobs

It turns out it is nice to use system first in the hierarchy for cicero.  Also both hydra and cicero are ok with a deep hierarchy of attributes.

* Refactoring

* Add mkFlakeCiJobs

* Avoid `:` in ciJobs and hydraJobs

* Use cabal names again in ciJobs

* More updates

Turns off code coverage by default.
Rename flattenChecks to mkFlakeChecks.
Adds flake packages to ciJobs and hydraJobs.

* Expand comment
2022-10-11 23:52:50 +13:00
Hamish Mackenzie 11f6d7ae56 Use pkgsBuildBuild for evalPackages default (#1739)
Instead of `buildPackages` which is actually pkgsBuildHost.  This makes sure that tools like `gdb` and `gcc` that we might depend on indirectly are the purely native ones (not versions for cross compiling).
2022-10-07 00:38:39 +13:00
Mango The Fourth e49b15fefc Choose proper llvm version for llvm-hs and make stack infra work like stack does (#1724)
* update llvm-hs llvm from 11 to 12

* allow passing version args to build-tools; fix llvm-hs build-tools, pass allRefs to builtins.fetchGit to allow fetching non-standard-refs (to mirror stack behaviour)
2022-10-04 23:20:50 +13:00
Hamish Mackenzie 7462e537ef Fix building the stack tool (#1723)
Fixes #218

Tested with:

```
nix-build -E '((import ./. {}).pkgs-unstable.haskell-nix.tool "ghc924" "stack" "2.9.1")'
```
2022-09-30 21:54:38 +13:00
Hamish Mackenzie 9c20232d0f Fix pcap library build (#1704)
Fixes #840
2022-09-20 22:26:16 +12:00
Hamish Mackenzie 4c8bbbd3ed Add flake.variants (#1661)
* Add flake.variants

This allows flakes to easily include variations of the
project by with different project arguments.
Anything you can pass to `project.addModule` can be used.
For instance to include variants using ghc 9.2.4:

```
flake.variants.ghc924.compiler-nix-name = pkgs.lib.mkForce "ghc924";
```
Then use it with:

```
nix build .#ghc924:hello:exe:hello
```

This change also:

* Exposes add `combineFlakes` and `rawFlake` for more control over how flakes are combined.

* Includes package coverageReports to the `hydraJobs` of the flakes.

* Tries to make the materialisation concurrency test more reliable
2022-09-16 22:21:54 +12:00
Hamish Mackenzie e922b0a730 Fix for haskell-language-server 1.8 (#1697)
* Fix for haskell-language-server 1.8

It looks like two of the plugins have not been updated in hackage yet (qualifyimportednames and stylishhaskell).

* Add modified ghcide patch for issue 1455

* hlint plugin only works with ghc902

Co-authored-by: cydparser <cydparser@gmail.com>
2022-09-16 14:49:14 +12:00
Hamish Mackenzie 6c7f9d0042 Use cabal 3.8 (#1641)
A bug was fixed in cabal 3.8 (https://github.com/haskell/cabal/issues/6771) that haskell.nix relied on for `pkg-config` in support.  To work around this we added a dummy `pkg-config` that `cabal configure` now uses when haskell.nix runs it `cabal configure` internally.  That returns version information for all the `pkg-config` packages in `lib/pkgconfig-nixpkgs-map.nix`.  This mapping has also been expanded based on the results of searching nixpkgs for `*.pc` files.

This update also includes workarounds for:

https://github.com/haskell/cabal/issues/8352
https://github.com/haskell/cabal/issues/8370
https://github.com/haskell/cabal/issues/8455
2022-09-13 12:00:04 +12:00
Las Safin 3bbbb40cc0 Allow merging cabalProject{,Local,Freeze} (#1638)
* Allow merging cabalProject{,Local,Freeze}

* Specify types of `sha256map` and `configureArgs`

* Fix type of `sha256map`
2022-09-07 17:10:39 +12:00
Hamish Mackenzie f43c5cca30 Avoid IFD (#1640)
I forgot this also avoids and IFD when I suggested it could be removed. See #1588
2022-09-02 17:29:47 +12:00
Las Safin fc5a5b4888 cabalProject': Consider cabalProjectLocal even if cabalProject argument is null (#1588)
* `cabalProject'`: Consider `cabalProjectLocal` even if `cabalProject` argument is null

* Respond to review
2022-09-02 13:22:07 +12:00
Yvan Sraka bc1de42afa Fix #1587: the option shell.buildInputs does not exist ... (#1598) 2022-08-18 16:07:27 +02:00
Hamish Mackenzie c5b6b0c786 Remove old fix now that Cabal is not in nonReinstallablePkgs by default (#1541) 2022-08-18 18:42:12 +12:00
Hamish Mackenzie fe7d738070 Fix hls build for ghc 9.2 (#1592)
This adds `flags: -haddockcomments` to the default cabal.project of haskell-language-server to fix building on ghc 9.2
2022-08-18 18:32:16 +12:00
amesgen e73f8f673b ghc-lib-parser-9.4: add global unique counters patch (#1580) 2022-08-09 15:45:43 +12:00
Hamish Mackenzie 05c0555400 Add flake support to hix (#1572)
This adds support for using nix flakes commands with hix.  This is done by creating a hidden `.hix-flake` directory and passing the source in using `--override-input`.

It also includes a `hix init` command to add a `flake.nix` and `nix/hix.nix` configuration file.
2022-08-05 10:17:16 +12:00
Hamish Mackenzie 61dea04edb Nixify hackage-to-nix output (#1574)
We have been using `readFile` and `fromJSON` to read a `.json` a 60MB .json file.  This change puts the information contained in the json file into `.nix` files that are imported when needed (rather than all at once).  This seems to save around 1s at eval time.

Tested with:
```
time nix-instantiate -E '(import ./. {}).pkgs-unstable.haskell-nix.tool "ghc8107" "hello" {}'
time nix-instantiate -E '(import ./. {}).pkgs-unstable.haskell-nix.tool "ghc8107" "haskell-language-server" {}'
```

See also https://github.com/input-output-hk/nix-tools/pull/118
2022-08-04 18:31:16 +12:00
Hamish Mackenzie c2f14344f1 Add ghc 9.2.4 (#1566) 2022-07-31 21:41:50 +12:00
Hamish Mackenzie a443611ecf Add evalSystem and evalPackages project args (#1546)
This adds a way to specify the `evalSystem` or `evalPackages` explicitly when calling the `project` functions.

Currently if we want to make a `flake` that supports multiple systems we have few options:

* Require builders for all the supported systems (even just for `nix flake show`).

* Pass `--impure` so that haskell.nix can see `builtins.currentSystem` to set up `pkgs.evalPackages` to use that.  Unfortunately this prevents nix from caching some of the work it does and often results in it recalculating for each supported system when it would otherwise be cached and take no time at all.

* Add an overlay to replace `evalPackages`.  This works, but it is not straight forward.

* Materialize the nix files for the project.

This change allows `evalSystem = "x86_64-linux";` to be passed telling `haskell.nix` to run `cabal` and `nix-tools` on that system.  The user will have to have a builder for that system, but does not need to have builders for the others (unless building outputs for them).
2022-07-28 20:03:05 +12:00
Kobayashi 4e100b2ad9 enable internal-interpreter flag for ghc (#1536) 2022-07-02 21:07:09 +12:00
Andrea Ciceri 2c1701b681 Supporting ca-derivations experimental feature (#1494)
* Supporting `ca-derivations` experimental feature

* Improved `contentAddressed.include` option description

* Ensure deterministic output for content addressed components

* Comment transformed into a Nix comment

To avoid possibly useless rebuilds

* Use `modules` arg `contentAddressed` flag

* Tutorial about CA derivations

Co-authored-by: Hamish Mackenzie <Hamish.K.Mackenzie@gmail.com>
2022-06-23 12:39:35 +12:00
Hamish Mackenzie 2a89c68994 Build ghci/ghc with internal interpreter (#1520)
Fixes #1512
2022-06-22 16:00:58 +12:00
Hamish Mackenzie d3ba497b5f Fixes to help building of all packages in stackage (#1503)
These are the less controversial changes from #1251
2022-06-02 22:45:09 +12:00
Hamish Mackenzie 4b61024e55 Fix for ghc-lib-parser 9.2 and haskell.nix patched ghc (#1502)
Fixes #1488
2022-06-02 15:00:54 +12:00
Hamish Mackenzie 95faec6038 Default reinstallableLibGhc to true (#1498)
It fixes more things than it breaks now.
2022-06-02 13:21:12 +12:00
Hamish Mackenzie fa2fa131fe Add ghc 9.2.3 (#1491)
Also:

* Updates the GHC's built on CI
* Use Cabal 3.6.2.0 for default Setup
* Fixes haskell-language-server and hlint on CI
2022-06-01 19:33:58 +12:00
Travis Whitaker 449d80f722 default enableSeparateDataOutput to true (#1476) 2022-05-25 00:18:33 +12:00
Hamish Mackenzie 82bc945818 Fix ghc 9 windows cross compilation (#1450)
Fixes Windows cross compilation for GHC 9.0 and 9.2.

Updates wine to use the version that is included with the chosen Nixpkgs (it used to be pinned to an older version).

Moves the configuration of the GHC source into the GHC derivation.  This should make adding Hadrian support easier.

Propagates library dependences (not just pkgconfig ones) on windows so that any DLLs in those libraries can be copied for TH evaluation and to the `/bin` directory of executable components.

Adds gcc and mfcgthreads as library dependencies on Windows so that the DLLs they include will be found.

Use `$pkgsHostTarget` (instead of `ghc-pkg`) to find all the DLLs can copy them to the `/bin` directory of executable components.

Adds support for __int128_t and __uint128_t to language-c to fix aarch64-darwin builds.

Fixed reinstalling packages that come with patched versions in ghcjs.
2022-05-19 20:21:16 +12:00
Shea Levy d82e4c0e24 Merge branch 'external-static-8.10.4'
Add external static plugins patch to Plutus GHC
2022-05-03 13:38:16 -04:00
Hamish Mackenzie 0a847d9ab9 Fix ghcide 1.7 and ghc810420210212 (#1462) 2022-05-03 21:07:31 +12:00
Shea Levy bfeea3e894 Allow packages to specify external static plugins 2022-05-02 11:08:42 -04:00
Hamish Mackenzie f707aa2e75 Fix hls conflict with unboxed tuple (#1457)
This is Maxim Koltsov's work around for building `haskell-language-server` with the haskell.nix compilers that include unboxed tuple patch.

See https://github.com/haskell/haskell-language-server/issues/2860#issuecomment-1110861573
2022-04-29 01:13:56 +12:00
Hamish Mackenzie f3ea06dcac Work around for packages in lts that do not install. (#1437)
For ghc 9.0.2 Haskell.nix will use the `stm`and `filepath` source that came with `ghc` when the version desired matches.  This is because 9.0.2 shipped with packages that differ from the same version in hackage.

`reinstallableLibGhc` is fixed for GHC 8.10 and above.  Rather than including a patch file this works by:

* Setting the `subDir` to the `compiler` directory when building.  That way relative paths to other parts of the `ghc` source tree (outside the `compiler` directory) still work.
* Files that are needed, but generated when `ghc` builds are added from the `generated` output of the ghc derivation.

`nonReinstallablePkgs` is now sorted and deduplicated before it is used (this reduces the chance of rebuilds when the list is refactored).
2022-04-20 15:25:21 +12:00
Hamish Mackenzie e81f3bb011 Avoid filtering repo to just 01-index.tar.gz file (#1432)
When downloading a `repository` block we get a number of files (not just the index).  For some repositories these files will be necessary for `cabal configure` and the vanilla ones created by haskell.nix will not work.  This change keeps these extra files and combines them with the main hackage index using `lndir`, so that changes to the repo will not require a new copy of the hackage index in the store.

This change also introduces `inputMap` that allows flake or niv inputs to be used to pin repository.  It also works with `source-repository-package` blocks.
2022-04-14 02:35:37 +12:00
Hamish Mackenzie fa2d8a9b6f Add ghc 9.2.2 (#1394) 2022-03-08 14:34:04 +13:00
Hamish Mackenzie 2576a948b5 Improve support for external Hackage repositories (#1370)
* Improve support for external Hackage repositories

This change builds #535. `repository` blocks in `cabal.project` parsed and `cabal` is used to automatically downloaded them.  Then `hackage-to-nix` is used to produce the nix required.

To make it work with restricted eval (on hydra for instance) we need to include a sha256 like this:

```
repository ghcjs-overlay
  url: https://input-output-hk.github.io/hackage-overlay-ghcjs
  secure: True
  root-keys:
  key-threshold: 0
  --sha256: sha256-EPlLYPmIGtxeahlOspRzwJv+60N5mqrNC2BY4jZKceE=
```

To find the correct `sha256` put in an invalid one and attempt a build.
2022-02-18 00:42:11 +13:00
Hamish Mackenzie f67cf8e439 Use updated nix-tools (#1365) 2022-02-09 22:08:43 +13:00
Shea Levy 50fd86f249 call-cabal-project-to-nix: Allow overriding source-repository-package entries. (#1354) 2022-01-27 08:27:22 +08:00
Moritz Angermann 001df758bf fix ghcjs (#1311) 2022-01-09 03:11:37 +13:00
Hamish Mackenzie 6101c6ea7b Add GHC 9.0.2 (#1338)
Co-authored-by: Ollie Charles <ollie@ocharles.org.uk>
2022-01-09 03:10:05 +13:00
Javier Sagredo 0e2ae928e2 Rename executable-profiling flag as suggested by Cabal (#1136) 2021-12-27 15:28:59 +08:00
Tom Prince a68a7dda41 Add nixos-21.11 builds. (#1304)
* Add nixos-21.11 builds.

* Remove references to nixpkgs-20.09.
2021-12-07 12:55:20 +13:00
Hamish Mackenzie 24b421cbfc Add ghc 9.2.1 and update internal cabal to 3.6.2 (#1286) 2021-11-13 12:43:04 +13:00
Jean-Baptiste Giraudeau 1205c42154 Some smalls improvements (#1271)
* Use builtins.fetchGit{allRefs=true;} if no ref provided.

 this allows to not being explicit about non-default branches.

* Pass buildProject as arg to first level project modules,

so that it can be used in, eg., shell definition.

* Add hsPkgs to projects modules config.

* Add benchmarks to generated project.flake packages
2021-10-22 14:23:48 +13:00
Hamish Mackenzie 1f4c2c9b08 Add GHC 8.10.7 (#1220) 2021-09-01 22:43:31 +12:00
Teo Camarasu f624ca5662 Add GHC-8.10.6 (#1214)
Add GHC-8.10.6

Co-authored-by: Peter Becich <peter@simspace.com>
Co-authored-by: Teo Camarasu <teofilcamarasu@gmail.com>
Co-authored-by: Hamish Mackenzie <Hamish.K.Mackenzie@gmail.com>
2021-08-31 04:19:40 +12:00
Hamish Mackenzie 3835023cda Add package.buildable option (#1205)
* Add `package.buildable` option

Turning off building for a whole package requires setting `buildable = lib.mkForce false` on each of the components of the package.  This change adds support for `package.buildable = false` to make it easier.

So:

```
packages.marlowe-actus.components.library.buildable = lib.mkForce false;
packages.marlowe-actus.components.exes.marlowe-actus-test-kit.buildable = lib.mkForce false;
packages.marlowe-actus.components.tests.marlowe-actus-test.buildable = lib.mkForce false;
```

Can be replaced with:

```
packages.marlowe-actus.package.buildable = false;
```
2021-08-19 00:52:59 +12:00
Hamish Mackenzie f8a0b92bc3 Add patches speeding up cabal build-tool-depends (#1200)
* Add patches speeding up cabal build-tool-depends

* Add missing brackets and fix paths

* Fix up patches for 3.4

* Fix missing file from patch

* Add comments
2021-08-14 12:05:58 +12:00
Hamish Mackenzie 674f5b0a3d Better support for source-repository-packages, only include planned components and pick latest packages (#1166)
This change updates to the latest `nix-tools` to get the following fixes (there are 3 PRs in nix-tools, but just the one in haskell.nix to avoid having to update the materialized files multiple times):

## Better support for source repository packages

* https://github.com/input-output-hk/nix-tools/pull/107

Currently these are replaced by the `cabalProject` functions with regular `packages:` before running cabal configure.  Cabal does not treat these the same (the setting of `tests:` and `benchmarks:` in the `cabal.project` file):

* The plan found by `cabalProject` may not match the one used when running `cabal`.
* The performance of the solver may not be consistent with running `cabal`.

This change replaces `source-repository-package` with another `source-repository-package` pointing at a minimal git repo.

## Only include planned components

* https://github.com/input-output-hk/nix-tools/pull/108

Only the components in the `plan.json` are now included in the haskell.nix cabal projects.  This avoids missing dependencies attempting to build components that were not in the plan.  Should fix #993.

## Pick latest packages

* https://github.com/input-output-hk/nix-tools/pull/109

When the same package occurs more than once in a `plan.json` file (perhaps because it is needed both by the project itself and by one of the `setup` dependencies or `build-tool-dependencies` of the project) the latest version will now be the one picked by haskell.nix. This is a work around for a common issue with `cabal-doctest` when cross compiling to windows (an old version of Win32 is used even if a newer one was required by the projects `constraints`).
2021-07-23 14:27:56 +12:00
Hamish Mackenzie 6b28399864 Add Hix wrappers for Nix tools (#1053)
The `hix` tools are wrappers for the various `nix` tools that
use `haskell.nix` without the need to add any `.nix` files.

This is useful for:

* A quick way to try out haskell.nix for new users.

* Using haskell.nix to work on projects that do not have
  `.nix` files.

* Testing to see if `haskell.nix` can build a project.

* Making `flake` and `non flake` configurations to check `haskell.nix`
  treats them the same.

The configuration arguments for `Hix` can be (from highest precedence to lowest):

* Passed on the command line with `--arg` (or `--argstr` for string args).

* Placed in `nix/hix.nix` file in the project dir.

* Placed in `~/.config/hix/hix.conf`

Boilerplate `default.nix`, `shell.nix` and `flake.nix` files can be added to a
a project with a `nix/hix.nix` file to make it work with the standard `Nix`
tools.
2021-06-26 17:58:06 +12:00