Commit Graph

220 Commits

Author SHA1 Message Date
Kirill Boltaev
20e9f66b84
Fix a small typo (#1233) 2021-09-10 14:08:09 +12:00
Hamish Mackenzie
58dff9550b
Update some older GHC materialization files (#1222) 2021-09-01 20:21:30 +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
20297c6725
Ignore .gitignore when making minimal git repo (#1198)
Files in the git repo may also be in `.gitignore`.  We still need these files in our minimal version of the repo.

This fixes #1195
2021-08-11 16:33:48 +12:00
Hamish Mackenzie
d5d304d5b5
Flakify all inputs (#1180)
* Include dependencies of haskell.nix that were tracked in `nix/sources.json`
  as flake inputs (`flake.lock` replaces `nix/sources.json`).
* Use `flake-compat` to continue to provide a compatible interface for non
  flake projects.

Co-authored-by: Alexander Bantyev <balsoft@balsoft.ru>
Co-authored-by: Shea Levy <shea@shealevy.com>
2021-08-06 15:54:39 +12:00
Hamish Mackenzie
755f3cd848
Add ole32 and rpcrt4 stubs (needed to build process package on windows). (#1172) 2021-07-23 18:16:40 +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
Moritz Angermann
920ac43ee1
Update system-nixpkgs-map.nix 2021-07-09 15:24:31 +08:00
Teo Camarasu
3856d2d24d
Improve shellFor selectComponents performance (#1146)
* factor out isSelectedComponent

* Optimise `flatLibDepends`

We no longer force the `outPath` attribute to avoid instantiating the
derivation, which is expensive
2021-06-28 16:46:19 +12:00
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
a5b74bf002
niv update nixpkgs-unstable and add ghc 8.10.5 (#1121) 2021-06-15 19:50:45 +12:00
Michael Peyton Jones
8e146f8d7d
Fix typo in eval-time repo fetching (#1135)
This was backwards.
2021-06-12 08:54:19 +12:00
Hamish Mackenzie
6483dfaa92
Add gmodule pkg-config mapping (#1123) 2021-05-22 22:30:14 +12:00
Hamish Mackenzie
618ff607d3
Fix shellFor components argument (#1079) 2021-04-08 15:33:09 +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
Dennis Gosnell
6c627b429b
support cabal-doctest (#427)
* Add test.

* wip

* Fix merge regression

* Combine drv, drv.source and drv.dist for doctest

* Skip cabal-doctests test when cross compiling

* Add the --no-magic flag to the .cabal file for the cabal-doctests test.

This appears to be necessary on OSX.

The --no-magic flag stops the doctest executable from expanding path
arguments, trying to locate the package db, etc.

This shouldn't be necessary with cabal-doctest, since all the
necessary options to pass to doctest are computed when running the Setup.hs
script.

See
https://github.com/input-output-hk/haskell.nix/pull/427#issuecomment-605761780.

* Fix cabal-doctest support

* Skip cabal-doctest test plan cross compiling

* More fixes for cabal-doctest

* Skip cabal-doctest tests when cross compiling

Co-authored-by: Moritz Angermann <moritz.angermann@gmail.com>
Co-authored-by: Hamish Mackenzie <Hamish.Mackenzie@iohk.io>
Co-authored-by: Hamish Mackenzie <Hamish.K.Mackenzie@gmail.com>
2021-03-20 14:25:30 +13:00
Hamish Mackenzie
44ecbc8ff8
Improve cleaning of stack projects (#1074)
Should help with #1013
2021-03-19 10:25:32 +13:00
Hamish Mackenzie
9085d9f44e
Fix cleanGit submodule support performance issue (#1072)
Currently in order to support submodules all the directories are included (but not all files) when building the whitelist.  This is done because we need the `.git` files (or directories) the contain to be present when we run `git ls-files --recurse-submodules`.

Including every directory causes two performance issues:

* Creating a directory in your repo (even empty one not added to git at all) will require the whitelist to be recalculated.

* Recalculation of the whiltelist may be slowed down if there are a large number of directories.  In particular `lstat` is called on every file (probably to get the right `type` to pass to the filter function).

The fix is to use `git submodule status --recursive` to get a list of all the submodule directories.  Then the `.git` files (or directories) in them can be included.  This has to be repeated until all the submodules are known (as `--recursive` will not see the submodules until the parent module is included).
2021-03-18 19:49:10 +13:00
Hamish Mackenzie
dff62ec5bd
Non deterministic failures should not be deferred (#1075)
It looks like `callCabalProjectToNix` can fail in its `cabal` call with the following error:

```
open: permission denied (Permission denied)
```

Then running the same derivation locally works.  If the error is deferred there is no easy way on hydra to retry.

This change makes it so only solvers errors (which should hopefully be deterministic) are deferred.  All other errors will go back to being eval time errors meaning they should be automatically retried at the next hydra eval.
2021-03-18 19:45:52 +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
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
cb264f6f6a
Add project.plan-nix.freeze (#1055)
Issues with `cabal.project.freeze` files can be tricky to debug.
While it is possible to run without a freeze file and look
at the `plan-nix` or `plan-nix.json` (the `plan.json`) created when
haskell.nix configured the project, it would be nice to
also have the output of `cabal freeze` as it will be in the
correct format and contains a different subset of `plan.json`
than the `plan-nix`.

This might also be useful for automating updating of `.freeze`
files.
2021-03-04 16:46:35 +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
39560d445e
Fix filtering package in root of project (#1041)
When a package is not in a subdirectory, but instead
in the root of the project the cleaning of the package
source was broken.

This might explain why some `cabal.project` file
based projects might also see be affected by #1013.
2021-02-15 16:37:15 +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
ismaelbouyaf
4729034750
Add "branch" information for builtins.fetchGit (#1019)
The builtins.fetchGit used by haskell.nix clones only the subset of a
repository corresponding to HEAD. So if we have a workflow that has a
branch "development" as HEAD, but the stack.yaml only targets commits
from "master", then it will be unable to fetch any commit.

Fixes #592
2021-02-03 13:16:02 +13:00
Alexander Vieth
80f3a848fb
add pcap -> libpcap to the system pkgs map (#1014) 2021-01-25 00:30:16 +13:00
Hamish Mackenzie
e6ba58f72f
Use combinePath instead of + for data files. (#1007)
Makes sure "/" character is added when needed.
2021-01-20 18:22:49 +13:00
Hamish Mackenzie
6e34587fc8
LicenseRef-OtherLicense is not free = false (#1006)
The [dependent-map](https://hackage.haskell.org/package/dependent-map)
package for instance is not clear on which free license applies to
which parts of the code, but that does not mean it is not free.

`cabal2nix` maps LicenseRef-OtherLicense to `meta.license = "unknown"`

`cabal-to-nix` and `haskell.nix` map it to a more detailed attribute
set but it includes `free = false` and that causes packages like
`dependent-map` to fail to install when `allowUnfree` has not been set.

This change removes the `free` attribute altogether, which seems more
principled than asserting that the `OtherLicense` cannot be `free`.
2021-01-20 00:27:18 +13:00
Hamish Mackenzie
505130bfda
Use the source sub directory when running tests (#1005) 2021-01-19 18:28:33 +13:00
Hamish Mackenzie
06a67e6835
Fix issue where subDir was applied twice (#1004)
This was breaking cleaning of components when a parent dir was needed.

So `hs-source-dirs: x` was ok, `hs-source-dirs: x/y` would fail.
2021-01-19 09:38:10 +08:00
Hamish Mackenzie
22ad57c7e7
fix the way the isProject package flag is set (#1003) 2021-01-19 10:58:24 +13:00
Jakub Kopański
36a85c8b34
Add vulkan to pkgconfig-map (#1001)
* Add vulkan to pkgconfig-map

* Explain decision to map vulkan to vulkan-loader
2021-01-18 12:51:59 +00:00
Michael Peyton Jones
8455f75c8c
Use configuration-nix to include freetds dependency of the odbc package (#1000)
I think this is more correct: other package that depend on the system
odbc package may not need freetds, the problem is that the Haskell odbc
package doesn't declare its dependency on freetds.
2021-01-16 13:16:00 +13:00
Alexander Shestakov
17e2b7c69f
Allowing projects with odbc or hdbc-odbc to be built (#997)
* Adding odbc alias to the unixODBC package

* Adding odbc alias to the unixODBC package

* Adding odbc alias to the unixODBC package

* Adding comments about odbc package dependencies
2021-01-15 09:10:14 +00:00
toonn
07df700531
Spdx license expressions (#859)
* Add parser combinators to parse SPDX license expressions

The most important parser is `compoundExpression` it parses any SPDX
license expression into a list of SPDX simple-expressions.
The rationale is Nixpkgs' license metadata isn't capable of
distinguishing between the AND and OR relationships.
License exceptions aren't currently taken into account.

* Add tests for the SPDX parser combinators

I simply added a file with expressions that are expected to fail to
parse or parse successfully.

* Add the SPDX license list

The SPDX license list as attrsets following the nixpkgs lib.licenses
convention.

This uses fetchurl which is not ideal because it's not available during
pure evaluation.

It does not yet include the SPDX exceptions list.

* Refactor cabal-licenses.nix to use spdx/licenses.nix

The handling of the generic licenses is undecided still. Some have been
removed because they have better official identifiers.

* Refactor license mapping in builders

The common code in the comp- and setup-builders has been extracted and
refactored to use the SPDX expression parser.

* Use spdx-license-list-data from nixpkgs

This conveniently solves the impurity problem with using fetchurl : )
I'm not sure threading `pkgs` through everything to get access to the
spdx license list package is the right way to go about this.

* hscolour to "LGPL-2.1-only" and remove "LGPL"

* Use evalPackages for spdx and move shim to overlay

* Better fix for LGPL packages.

Co-authored-by: Hamish Mackenzie <Hamish.Mackenzie@iohk.io>
2021-01-14 14:33:40 +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
paumr
a045d79264
Updated system-nixpkgs-map.nix and a default for X11 package (fixes #984) (#988)
After investigating adding a project argument to override the
mapping of libs to packages we realised we could fix the X11
package by updating `modules/configuration-nix.nix`.

We also updated `system-nixpkgs-map.nix` to allow multiple
packages to be mapped for a single library (turned out not
to be necessary for X11).

Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
Co-authored-by: Hamish Mackenzie <Hamish.Mackenzie@iohk.io>
2021-01-08 13:10:00 +13:00
paumr
91a7fa9407 moved xorg packages to correct attributeset
I'm wondering how/if this worked before, i couldn't find most xorg
packages on their previous path.
(Neither on the current version of nixpkgs nor on nixpkgs anno 2018)
2021-01-01 23:27:56 +01: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
Zhenya Vinogradov
99fdad7640
Fix stack.yaml filtering when resolver file is in a subdirectory (#943)
* Fix stack.yaml filtering when resolver file is in a subdirectory

`maybeCleanedSource` tries to include the resolver file into the cleaned
source, if a resolver is specified, but it was only working when the
file was in the root of the project, because all directories would be
filtered out.

* fixup! Fix stack.yaml filtering when resolver file is in a subdirectory

Fix calculating relPath for paths using subDir

* Add test case for local stack snapshot located in a subdirectory
2020-12-09 17:43:36 +13:00
Michael Peyton Jones
dbff20d0c8
Make haskell.nix quieter (#944)
* Remove unconditional trace for index-state

We already have messages for unusual cases (like using the latest
index-state). This message is unconditional, so quite noisy.
We include the actual index-state in the builer log so it's available if you
want to check it.

* Move source-cleaning warning to builder log

It's not *that* interesting, and someone who cares will likely check the
log.

* Move shellFor trace message to builder log

Not that interesting, really.

Co-authored-by: Hamish Mackenzie <Hamish.Mackenzie@iohk.io>
2020-11-27 14:18:15 +13:00
Michael Peyton Jones
20b6629205
Drop 19.09 support (#947)
* Drop 19.09 support

This is a year old. NixOS doesn't even support the last stable release,
let alone the one before that.

Also cuts our CI size by a third, which is always nice.

* Remove 19.09 compatibility pieces
2020-11-27 10:34:31 +13:00
Michael Peyton Jones
1dce3ffcb3
Don't reference scripts directly in materialization messages (#945)
Instead, give a hint as to how to get the appropriate scripts
as attributes.

Fixes #456, #877.
2020-11-27 00:33:51 +13:00
Hamish Mackenzie
e4be77ee93
Expose the plan.json file as plan-nix.json (#935)
Make the plan.json file available in case we need to debug plan-to-nix
2020-11-23 18:00:28 +13:00
Hamish Mackenzie
df98a8b0fd
Add an index-state to ghcjs-project (#928)
This should help guard against unwanted updates.
2020-11-18 21:15:21 +13:00
Hamish Mackenzie
7078b145e9
Add support for ghcjs 8.8 and making ghcjs bundles (#828)
Fixes ghcjs 8.6.5 and 8.8.4.

Uses emscripten for ghcjs 8.8 and adds scripts for building ghcjs 8.8.

Many fixes for ghcjs test failures.

Includes relocatableConfigFiles for making relocatable ghcjs bundles.
2020-11-17 22:22:53 +13:00