Commit Graph

185 Commits

Author SHA1 Message Date
Michael Peyton Jones
d3bfa5789f
Improve index-state error message (#667)
Fixes #533.
2020-06-10 18:30:03 +08:00
Michael Peyton Jones
141cd02f29
Fix path to nix-hash (#664) 2020-06-10 12:10:06 +12:00
Moritz Angermann
54f6fbf607
fix ghc being picked from the wrong package set (#663) 2020-06-09 20:05:24 +08:00
Hamish Mackenzie
edd1d21577
Ignore extra ghc-options in dummy ghc. Fixes #656 (#658)
Since the dummy ghc is only used for getting information about ghc,
it should be safe to ignore these.
2020-06-09 14:58:03 +12: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
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
6dc93ce1d4
Fix missing -lnuma when linking musl test exes (#652)
Also:

* Reduce the number of calls to override functions

* cp -L is not needed for user to cp calculateNoHash

* Update dummy-ghc files
2020-06-05 12:54:33 +12:00
Maxim Koltsov
db409cf3a0
Allow cabal.project* files to be symlinks (#651) 2020-06-05 02:27:57 +12:00
Hamish Mackenzie
3356114206
Symlinks in materialized cause permissions err (#650) 2020-06-04 19:57:50 +08:00
Hamish Mackenzie
e5a052243b
Add support for cabal.project.local (#632)
Running `cabal v2-configure` overwrites the `cabal.project.local` file
so this change adds the contents onto the end of the `cabal.project`
file before running `cabal v2-configure`.

You can override this behavior passing `cabalProjectLocal = ""`

Treats cabal.project.feeze the same way as `cabal.project` and
`cabal.project.local` in that it will still use it if it is filtered by cleanGit.

This change also adds `cabalProjectFileName` arg so that
we can override the default `cabal.project` name.
2020-06-01 23:12:24 +12:00
Hamish Mackenzie
c474dcec4a
Add #! to dummy-ghc, --version and use bash case (#640)
This change improves the dummy ghc scripts by adding a bang pattern,
supporting `--version` and using bash case instead of lots of `elif`

Includes the same fixes for dummy-ghc-pkg
2020-06-01 14:46:49 +12:00
Hamish Mackenzie
ecc72c1949
Add cleanGits and support it incabalProject (#631)
Some times it is handy to temporarily use a relative path between git
repos.  If the repos are individually cleaned this is not possible
(since the cleaned version of one repo will never include the files
of the other).

`cleanGits` allows us to specify a root directory and any number of
sub directories containing git repos.
2020-05-28 21:59:36 +12:00
Hamish Mackenzie
91a7ac7aab
Use evalPackages to write cabal.project file (#630) 2020-05-27 18:05:41 +12:00
Kirill Elagin
80541e1076
cleanCabalComponent: Do not fail on licenses in a subdir (#627)
When the `license-file` is not at the top-level, e.g. in the LICENSES
subdirectory, it didn’t have any chance of being included, as the
subdirectory was filtered out right away.

Include `licenseFiles` in the list of subdirs used for determining
“needed” subdirectories (the ones that will be kept).
2020-05-24 20:26:25 +08:00
Owen Shepherd
2a58affb4e
Fix foreign-library component prefix (#625) 2020-05-24 09:35:15 +08: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
Zhenya Vinogradov
7d4751b066
pkgconf-nixpkgs-map.nix: add libsecp256k1 (#616)
Used by `secp256k1-haskell` package
2020-05-18 18:39:07 +08: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
341341cbdd
Reduce cabalProject IFD deps using dummy GHCs (#607)
The `cabalProject` function works by running `cabal v2-configure` followed by `plan-to-nix`.  However for `v2-configure` to correctly calculate the plan (including flag settings and buildable components) it needs to know what GHC we want to use.

This causes significant problems:

* For hydra to assemble a list of jobs from `components.tests` it must first have GHC that will be used.  If a patch has been applied to the GHC to be used it must be rebuilt before the list of jobs can be assembled.  If a lot of different GHCs are being tests that can be a lot of work all happening in the eval stage where little feedback is available.

* Once the jobs are running the compilation of the GHC needed (the eval stage already must have done it, but the outputs there are apparently not added to the cache) happens inside the IFD part of `cabalProject`.  This causes a very large amount of work to be done in the IFD and our understanding is that this can cause problems on nix and/or hydra.

* When using `cabalProject` we cannot examine the properties of the project without building or downloading the GHC (less of an issue as we would normally need it soon anyway).

The solution here is to:

* Create a dummy `ghc` and `ghc-pkg` from the real ones by capturing the `ghc` and `ghc-pkg` outputs that `cabal v2-configure` requests.

* The dummy `ghc` and `ghc-pkg` is used instead of the real one in `cabalProject` when running `cabal v2-configure`. 

* The captured outputs are materialized into the haskell.nix repo so that the real GHC is only needed when `checkMaterialization` is set.
2020-05-15 14:00:00 +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
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
Hamish Mackenzie
26d7b00f1d
Custom args to cabal new-configure IFD functions (#305) 2019-11-08 17:53:05 +13:00
Hamish Mackenzie
707c7b82f4
Fix cleanGit for repositories with no submodules (#304) 2019-11-08 17:52:41 +13:00
Hamish Mackenzie
5393c501e2
Fix cleanGit when using a worktree (#282)
Joachim's original version had logic to handle git worktree's but
it was not wired into the updated version that uses cleanSourceWith.
2019-11-06 22:44:09 +13:00
Hamish Mackenzie
fe5c3a2a04
components.setup is not a library (#292)
We added a setup component to allow overriding of the config used to
to build Setup.hs.  The code that deals with library components
was misidentifying this component as a library.
2019-11-05 00:52:58 +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
23e0c2fcea
Add subDir argument to cleanGit (#280)
Co-Authored-By: Viktor Kronvall <viktor.kronvall@gmail.com>
2019-10-30 15:09:45 +13: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
Hamish Mackenzie
fdcb2da2a8
Add default for shellFor packages (#242)
Uses the `isLocal` for property set by `plan-to-nix` and `stack-to-nix`
on packages where the source is referenced in the `cabal.project`
or `stack.yaml` file.
2019-10-01 11:10:11 +13:00
Hamish Mackenzie
6f566a6d5d Filter components using buildable flag (#240)
* Filter components using buildable flag

* Bump nix-tools

* Include components without buildable flag

* Test buildable components are filtered correctly
2019-09-26 13:47:03 +08:00
Hamish Mackenzie
c513afa420 Include --enable-tests in callCabalProjectToNix (#225) 2019-09-16 17:18:29 +08:00
Hamish Mackenzie
b4b8a30c5d Add libsoup-2.4 to pkgconf-nixpkgs-map.nix (#234) 2019-09-10 13:32:24 +08:00
Hamish Mackenzie
0366537651
Use new cleanSourceWith to filter component source (#209)
When trying to build haskell packages from local source using nix (
source code you have used `git clone` to retrieve and have modified)
it is often annoying that small changes can trigger a lot of components
to be built unnecessarily.  For instance if you change the code for
a test in a package it will often trigger builds of the library and
all its dependencies.

To avoid this problem we could manually set up `cleanSourceWith` calls
in nix to filter out files that are not need, but to do this every
component would be difficult and error prone.

This change automates this process using the information in the
packages `.cabal` file to filter the source of each component
automatically  when using `callCabalPlanToNix` (we should be able to
add it to `callStackToNix` too).

## How does it work?

* A new version on `cleanSourceWith` is used that adds a `subDir`
  argument.  It allows descending into a subdirectory to compose with
  cleaning the source.

* A new `--full` argument is passed to `plan-to-nix` by
  `callCabalPlanToNix` telling it to output extra information about
  the cabal packages in the plan (directories and filenames).

* `callCabalProjectToNix` uses the new `subDir` argument of
  `cleanSourceWith` when setting the packageSrc.

* `comp-builder.nix` and `setup-builder.nix` use a new
  `cleanCabalComponent` function to further clean the packageSrc
  using the new information in the `package` and `component`.

## hpack wildcards
`package.yaml` files can include wild cards and these are not handled
yet (they do not map to anything in the `.cabal` file and so are lost).
They will need to be added manually to the appropriate field
(eg. `packages.xyz.package.dataFiles`)

If your hpack file does not contain wildcards or if you are willing to
add the wildcards entries manually in nix it is still useful to
enable cleaning on hpack.

For example:

```
packages.ghc-toolkit.package.cleanHpack = true;
packages.ghc-toolkit.components.library.extraSrcFiles = [
  "genapply/**/**"
  "boot-libs/**/**"
  "ghc-libdir/**/**"
  ];
```
2019-08-26 12:27:47 +02:00
Rodney Lorrimar
d4869aab48 Add haskellLib.collectComponents (#224) 2019-08-24 10:29:43 +02:00
Bryan Richter
dadf29e84b callStackToNix: Enable ignorePackageYaml argument (#226)
This argument just translates to --ignore-package-yaml in the
invocation.
2019-08-16 19:31:42 +02:00
Luke Clifton
70bffa54b4 Add iconv -> libiconv mapping (#216) 2019-07-31 20:01:09 +10:00
Thomas Tuegel
3d79fa9520 cabal-licenses.nix: Add LicenseRef-NCSA (#212) 2019-07-27 10:03:24 +08:00
Hamish Mackenzie
dedb91e725 Add sha256 to source-repository-packages for restricted eval mode (#170)
* Add sha256 to source-repository-packages for hydra

This allows source-repository-package to be downloaded and replaced in
with `package: /nix/store/...` by callCabalPackageToNix so that `cabal`
and `plan-to-nix` do not need to download them.
2019-07-16 15:13:31 +08:00
Hamish Mackenzie
3d02d751f7 index-state from cabal.project by default (#169)
* index-state from cabal.project by default

Change callCabalProjectToNix to use the `index-state` specified in the
`cabal.project` file by default.
2019-07-16 13:28:20 +08:00
Moritz Angermann
ebb22334d5
Adds hackage-package. (#205)
* Adds `stackage-lts-set` and `hackage-package`.

This allows us to build a full stackage-lts-set, or a package from
hackage.

```
nix build '(with import ./. {}; (hackage-package { name = "lens"; version = "4.17.1"; })).components.library'
```
would build the lens library.

```
nix build '(with import ./. {}; (stackage-lts-set "lts-13.28")).lens.components.library'
```
would build the lens library component from the lts-13.28 stackage set.

* Drop lts-stackage-set

* Adds some docs
2019-07-15 20:47:02 +08:00
Hamish Mackenzie
6be886644f Cross comp. & callCabalProjectToNix/callStackToNix (#202)
* Cross comp. & callCabalProjectToNix/callStackToNix

This fixes an issue where the these IFD functions fail because they try
to build and run a cross compiled nix-tools on the build system.

It may also help if there are cross compilation issues with
setup-depends (they also access the buildPackages).

* Align stack-to-nix ifd with plan-to-nix ifd

This also fixes the restricted/pure eval issues with callStackToNix.

I've also made the tests run in restricted mode to catch these kinds of
issues.
2019-07-13 22:13:15 +08:00
Rodney Lorrimar
234e9e091d
docs: Add some information about mapping non-Haskell dependencies (#200)
Relates to #198
2019-07-13 17:54:53 +10:00
Michael Peyton Jones
9d251db79a Add custom errors for some missing attributes (#194)
* Add a custom error message for a missing stack resolver

* Make mkCabalProjectPkgSet robust to missing Hackage patches

* Add error for component prefix lookup

* Add a custom error for a missing GHC
2019-07-04 10:09:02 +10:00
Rodney Lorrimar
5ac12d01aa
builder: Install benchmarks properly (#175)
* builder: Install benchmarks properly

* builder: reduce duplication in test/benchmark installPhase
2019-06-21 12:21:58 +10:00
Moritz Angermann
54086725c5
Update default.nix
Adds comment regarding the `(x or null) != null` check.
2019-06-16 11:29:00 +02:00
Edward Amsden
bf133322bf Fix error in all component when a package has no library component (#176) 2019-06-15 08:21:32 +02:00
Moritz Angermann
03fd50f0b7
Run the nightly scripts to also update the index-state-hashes (#146)
* Run the nightly scripts to also update the index-state-hashes

This moves the index-state-hashes to `hackage.nix` as well.  Thus
we need to have a least one hackage.nix update in.

* fix import

* Update update-index-state-hashes.nix

Add comments.
2019-06-08 15:21:02 +08:00
Hamish Mackenzie
e632534506 Fix for haskell-gi packages (#148)
* Fix for haskell-gi packages

* Add comment explaining the hacky gi-* workaround
2019-06-02 21:14:14 +08:00
Rodney Lorrimar
8512832c32
Fix evaluation on Hydra (#153)
* Fix eval on Hydra

* Bump nixpkgs to latest 19.03

* Change unit tests into a derivation

Prevents Hydra from complaining about them.

* Add unpacked source pins to Hydra jobset

So that they are cached.
2019-06-02 07:21:21 +10:00
Hamish Mackenzie
bc01ebc05a Fix callCabalProjectToNix plans with source repos (#149)
* Fix callCabalProjectToNix plans with source repos

* nix-tools: wrap executables to provide dependencies

* cabalProjectToNix needs git for cabal source repos

When resolving source repos the `cabal` executable uses `git` from
the `PATH` (not using nix store reference).
2019-05-30 13:13:18 +08:00
Hamish Mackenzie
b82a06c37f Fix callCabalProjectToNix when using nix sandboxes (#154)
* Fix callCabalProjectToNix when using nix sandboxes

I am not sure why this works on hydra, but on default install of nix
on ubuntu it fails to rename the plan-and-src $out because it is made
read only by rsync.

* Add comment regarding the nix sanbox issue
2019-05-29 13:11:35 +08:00