* 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>
* 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>
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;
}
```
* 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.
* 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
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.
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.
* 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
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.
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.
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
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.
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`
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`.
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.
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.
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
* 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
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).
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`.