Commit Graph

116 Commits

Author SHA1 Message Date
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
Maxim Koltsov
5716c62f6b
Add sodium -> libsodium mapping (#587)
This is required by `saltine`, which in turn is pulled by newer `hnix`
and this is needed for `nix-tools`.
2020-05-07 11:23:50 +12: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
Jean-Baptiste Giraudeau
da0473aec3
Add GPL-2.0-or-later to cabal-licenses.nix (#586) 2020-05-06 20:59:00 +08:00
Moritz Angermann
0b1381b88d
Stage2 muslc only on x86 (#582)
Ideally we'd have equality on architecture here. For now special casing
x86 will suffice.
2020-05-05 11:58:22 +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
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
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
1f94c06e67
Use fetchGit for source-repo-package without sha (#554)
* Downloads using `builtins.fetchGit` when no sha is found.

* Adds a `lookupSha256` arg for when we can't change `cabal.project`.

* Outputs a message when the sha256 is missing that includes advice on how add one.
2020-04-21 00:10:54 +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
Joe Hermaszewski
303ed1133d
Add vulkan-loader to system package map (#528) 2020-04-02 14:52:41 +08:00
Michael Peyton Jones
17f1f63674
Delete noisy trace message (#526)
This fires at least 3 times for every haskell.nix project (bootstrap
happy, alex, and hscolor), and then again for every `cabalProject` and
`hackage-package`. Moreover, it isn't actually informative: it just says
`ghc` and `ghc-pkg` for the executables being used.
2020-03-31 11:59:55 +08:00
Hamish Mackenzie
0aa17d8afc
Use subDir not src to construct default names (#506)
When no name is provided to `cleanSourceWith` or `cleanGit` we
currently use `baseNameOf src` as a default.

This was cute, but it lead to cache misses.  For instance if
`x = cleanSourceWith { src = ./.; }` then `baseName src`
will be different when `src` resolves to "/nix/store/X"
than when it is in a local directory.  If people use
git worktrees they also may wind up with different
values for `name`. Anything that depends on `x.name` will
propagate the issue.

This change uses `subDir` if present or if it is not it encourages
adding a suitable `name` with a warning message.
2020-03-25 13:45:43 +13:00
Zhenya Vinogradov
cb3acc6bd5
Add AGPL-3.0-only and AGPL-3.0-or-later to cabal-licenses.nix (#503) 2020-03-20 20:15:03 +13:00
Michael Peyton Jones
614a675330
Add collectChecks functions (#498)
Fixes #482.
2020-03-20 19:34:40 +13:00
Rodney Lorrimar
0933c58908
Fix evaluation of haskellLib.collectComponents (#479) 2020-03-09 20:47:26 +10:00
Alexander Bantyev
6ef18c9efb
Make text-icu build by mapping the dependencies (#474) 2020-03-06 11:16:54 +08:00
Hamish Mackenzie
fbeb1e09aa
Fix issue with materialize and sandboxed builds (#399) 2020-03-04 17:06:24 +13: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
Michael Peyton Jones
2aa1329381
Improve collectComponents (#463)
Fixes #457.

- Components that don't have a library component will no longer break
`collectComponents "library"`.
- Avoid having lots of empty attribute sets.
- Don't set `recurseForDerivations` excessively.
2020-02-29 11:22:14 +13:00
Yorick
854485c09a
system-nixpkgs-map: add tensorflow, opencv (#465) 2020-02-29 11:20:51 +13:00
Robert Hensing
82115762ef
Add to nixpkgs map (#447)
* pkgconf-nixpkgs-map: Add nix dependencies

* system-nixpkgs-map: Add boost
2020-02-15 17:28:28 +13:00
Hamish Mackenzie
e1b57495cf
Fix source dirs with trailing slash (#445) (#446) 2020-02-14 11:21:04 +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
Jean-Baptiste Giraudeau
e346ccbef8
Equivalent to collectComponents with (_: true) as selection function (#438)
* Add collectComponents': collectComponents with (_: true) as selection function.

* Fix location of checks in documentation.
2020-02-09 16:56:35 +08:00
Alexander Bantyev
78526fca32
Pass name argument through cleanGit (#437) 2020-02-08 16:09:23 +13:00
Hamish Mackenzie
efb9a07d64
Enable benchmarks by default when calculating plan (#432) 2020-02-04 15:20:13 +08:00
Moritz Angermann
ab05ff7d89
Update call-cabal-project-to-nix.nix (#429) 2020-02-01 09:25:34 +08:00
Samuel Leathers
4afd58dc9d
fix paths for worktree when sandbox is enabled (#423) 2020-01-30 10:32:08 +13:00
Hamish Mackenzie
674cdf215e
Fix cleanGit for submodules of submodules (#413)
Repos that have submodules with submodules will have a `.git` file
that references the relative location of the submodules dir in the
`.git/modules`.  Without this file the contents of submodules of
submodules are excluded from the `cleanGit` output.
2020-01-23 17:19:11 +13:00
Jonas Carpay
50180fb684 Improve cleanGit error handling (#408) 2020-01-21 22:07:40 +13:00
Moritz Angermann
ff240d1716
Add selectProjectPackages (#406) 2020-01-17 12:17:18 +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
a84e3b55c6 comp-builder: changed attribute installedExe -> exeName (#394)
The bare exe name is more useful downstream than something prepended
with bin/.
2020-01-13 17:55:45 +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
Hamish Mackenzie
91e2341672
Exclude .source-repository-packages from plan nix (#379) 2019-12-21 17:30:01 -07:00
Jonas Carpay
fa610f476b Add lapack -> liblapack to system nixpkgs map (#376) 2019-12-20 17:43:38 +08:00
Hamish Mackenzie
41b72e182a
Keep source for component builds (#345)
This fixes and issue with TH functions like `makeRelativeToProject`
that can be used to keep a reference to source files.  If they are in
a temporary location that can result in surprising `file not found`
errors at run time.

It may also be useful for making debug symbols and the like refer to
real files.

There is a risk that keeping the source for all packages could expand
closure sizes (if for instance debug info is wanted, but you do not
want to keep the source in the store).  For that reason we have
made this an option that must be enabled.
2019-12-13 16:43:27 +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
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
5065fe9aae
Add LOCALE_ARCHIVE to haskellLib.check derivations (#344) 2019-12-03 23:02:13 +13: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
9345c4a182
Fix data-dir: when cleaning components (#332)
`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-27 15:12:19 +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
David Cao
cb8e3883b7 Add error message for empty src (#320)
When a project's source directory is empty (i.e. no files have been
added to the project's corresponding git repo), a more friendly error
message will now be printed
2019-11-19 09:27:49 +10: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
9b10945d98
Add passthru.run with wine support (#301)
This can be used to run tests, executables or benchmarks.
Instead of building drv build drv.run and the result should be the output of stdout.
2019-11-11 23:38:08 +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
3c78559621
Fix cleaning git submodules not in a worktree (#311)
When we are not in a worktree the submodule info is in the
`.git` dirs scattered throughout the repo itself.  In that situation
we need to copy the `.git` dirs into the temp location we are using
to run `git ls-files`.
2019-11-10 14:25:26 +13:00