Currently the ghc version is picked to match the `shellFor` project
and you cannot replace it by specifying `compiler-nix-name`.
This change fixes that and also uses `ghcOverride` so warning to asking
for a `compiler-nix-name` is not displayed when the compiler has already
been picked (by the project that shellFor is for).
Generalized version of the `cabalProject` and `stackProject`
functions.
Automatically selects the correct project type based on the
`projectFileName` argument if provided or what files exist in
the `src` directory if no `projectFileName` was specified.
If it cannot be determined which it should use the following
error message is given:
```
error: haskell-nix.project : both `stack.yaml` and `cabal.project` files exist set `projectFileName = "stack.yaml;"` or `projectFileName = "cabal.project";`
```
This is a simple way to specify the sha256 values for references
to git repositories that do not have a `--sha256:` comment in the
`cabal.project` file or a `# nix-sha256:` comment in the `stack.yaml`
file.
The tests demonstrate how to use `sha256map` with both
`cabalProject` and `stackProject` to build the
haskell-language-server from github with the sha256 hashes
needed to work with `--option restrict-eval true`.
* Use hydra-migration in check-hydra.nix
* mkdocs fix is now in nixpkgs 20.03 (so this drops our work around)
* Adds sanity checks for #660
* Add missing ${targetPrefix} to NIX_LDFLAGS
* Use eval system for callStackToNix.
* Improves pins.
Fix flake overlay attr
Solves the following error:
while evaluating the attribute 'overlays.combined-eval-on-build' at /nix/store/0gg5rsi7nvwlk2ky1w595qyjgwpqj35g-source/flake.nix:11:5:
value is a function while a set was expected, at /nix/store/0gg5rsi7nvwlk2ky1w595qyjgwpqj35g-source/flake.nix:10:15
Fixes#672 by using the first index-state that is > than desired
index state. It also passes `--index-state` to `cabal v2-cconfigre`
to make sure it cabal uses only the packages in the hackage
file that are before the specified date.
Fixes#540 by returning the `index-state` used back out of
`cabalProject` in the same way `plan-nix` is returned.
* 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
* 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>
Now that the defaultCompilerNixName is used to choose which GHC to use
for tools we need to update haskellNixRoots to make sure the common
tools wind up in the cache.
To do this we add the compilerNixName as a dimension in ci.nix.
This has the added bonus of ensuring the tests a run with the
supported versions of ghc (not just the default one).
haskellNixRoots is also updated to include the tools built with the
defaultCompilerNixName (in particular cabal-install was not pinned
and this was the likely cause of significant builds due to cache
misses).
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).
It turns out `git` depends on `gdb` in a round about way:
```
git -> openssh -> libfido2 -> systemd -> python libxml -> Cython -> gdb
```
Somewhere in that chain there should perhaps be a `buildPackages` so
that the `gdb` that is used is not the one for debugging code in
the `final` (but instead the one for debugging code in
`final.buildPackages`).
Using `final.buildPackages.git` causes two problems:
* Multiple versions of `git` (and that dependency chain
to `gdb` are needed when cross compiling).
* When `gdb` does not exist for `js`, so when cross
compiling with `ghcjs` `final.buildPackages.git` fails
to build at all.
* 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>
The newer versions of ghcjs use emscripten to deal with .c code.
The version of emscripten that is available by default in nixpkgs
does not include the "upstream" version of emscripten.
This commit takes the existing emscripten from nixpkgs and adds
the "upstream" version.
When declared as constant, read-only relocatable data are written to an unwriteable .rel.ro.data section. Being unwriteable, the gold linker doesn't put them inside the GNU_RELRO segment, but in a always read-only segment. Starting the relocation phase of such a built program then ends in a segmentation fault.
By declaring read-only relocatable data as writeable, they will be put inside a writeable .rel.ro.data section. The gold linker will then assume that those can be put inside the GNU_RELRO segment, that will only be writeable during the relocation phase.
The as assembler and ld linker will always consider the .rel.ro.data as writeable before relocation, and put the associated data in the GNU_RELRO.
Co-authored-by: Michivi <webmaster@michvi.com>
* 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>
* Profiled iserv for profiled builds
When trying to build profiled builds, we might end up in a situation
where the library we load requires symbols from the profiled rts. In
those cases we rely on the profiled RTS linked against iserv.
Also ghc has the slightly annoying preference of adding the `-prof`
suffix to the provided iserv program, thus we need two iservs now.
* Update mingw_w64.nix
Only prof, not debug.
Changing from absolute links to relative links increases the length of
the parameters passed during linking by half. For things that have many
dependencies, this results in linking failing with an "argument list too
long" error.
Fixes#562
This change also updates the CI configuration files to help make
it easier for CI to cope with this sort of change.
Co-authored-by: Richard Wallace <richard.wallace@simspace.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;
}
```
* Update nixpkgs pins to include 20.03, wobble
- Add 20.03
- Remove 19.03 (and old 18.09 file)
- Update 19.09 to latest
- Update github pin to 20.03
- Remove workarounds for 19.03
* Mark openssl as allowedInsecure
* Force python3 for mkdocs
* 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 PR adds a patch for GHC 8.6.5 to properly remove the atomic primops fallbacks on ARM architectures. Those primops called some GCC legacy synchronization functions that were not loaded during TH, ending in failure within `remote-iserv`. It turns out that the condition `!defined(arm_HOST_ARCH)` was never `true`, as `arm_HOST_ARCH` was actually defined (on ARM architectures) in a dependency of the `Rts.h` file.
This patch works for my use case (GHC 8.6.5 for armv6l). I haven't done any test on the other GHC versions.
This PR also includes a patch to actually use the native `pkgconfig` during cross-compilation.
Fixes#441
Authored-by: Michivi <webmaster@michvi.com>
This change updates the pins for nixpkgs to the latest upstream nixpkgs-19.*-darwin branches. It also moves the remaining fixes from the haskell-nix/channels/nixpkgs-19.*-darwin branches into overlays in haskell.nix.
471: wineTestWrapper: export Windows Path based on nativeBuildInputs r=hamishmack a=jbgi
otherwise `build-tools` are not available when running tests under wine.
Co-authored-by: Jean-Baptiste Giraudeau <jean-baptiste.giraudeau@iohk.io>
* 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
This commit cleans up iserv-related patches, especially for GHC 8.4, by
making sure they are exactly changes made upstream (only with merge
conflicts resolved).
Overall, there are three groups of patches now:
1. move-iserv is merely an upstream change that was merged between 8.4
and 8.6. The previous patch was probably some development version,
now it is the same as upstream.
2. iserv-autoconf was merged upstream between 8.6 and 8.8. The patch
consists entirely of replacing version numbers with variables,
therefore applying the same patch to 8.4 and 8.6 causes conflicts, so
we have two versions of the same patch for simplicity. Additionally,
the 8.6 is different from the upstream one in that it does not remove
the .cabal files, see the commit description in the patch for details.
3. iserv-cleanup was merged between 8.8 and 8.10. It applies cleanly to
8.8 and 8.6, however there is conflict in one line when applying it
to 8.4. As a workaround, when applying this patch to 8.4 we first
prepare the source to avoid the conflict, and then undo this change.
This allows us to use the same main patch for 8.4 as for 8.6 and 8.8.
Also, in all patches changes to .gitignore were manually removed, as
this file does not exist in the Nix checkout of src and this causes
the patches to fail.
* Add ghc 8.8.1 to the supported compilers
The `overlays/ghc.nix` overrides were not applied to the `ghc` used
to by the `exactDeps` and `envDeps` `passthru` derivations. This
resulted in each ghc building twice with only one of them being cached
by hydra.
This change fixes this by moving the exactDeps and envDeps for ghc
into sub directories of the output of the ghc derivation itself.
Co-authored-by: Hideaki KAWAI <kayhide@gmail.com>
* Use quick-cross for cross-compilation to avoid qemu crashes
* Bring over patches from my old fork of iohk-nix
* Expand Aarch32 patches to ghc-8.6.5
* Turn off shared builds when cross-compilging for linux ARM
* Update compiler/ghc/default.nix
* fix SETUP being build properly by the build stdenv (nixpkgs#56555 made NIX_DONT_SET_RPATH less restrictive; which showed up in 19.09).
* 19.09 fixes
* Update wine.nix
I found that if I added this to my stack.yaml:
ghc-options:
$locals: -ddump-to-file -ddump-hi
As specified in https://docs.haskellstack.org/en/stable/yaml_configuration/#ghc-options
Then my build would fail to evaluate with:
error: The option `packages."\$locals".package.identifier.name' is used but not defined.
So to fix it, we filter out these special package globs in mkStackPkgSet.
This commit also adds a regression test for that configuration option.
The LLVM versions specified for the ghc-8.6 series compilers in overlays/bootstrap.nix was LLVM 5, but these compilers state on the download page that they require LLVM 6. This resulted in a warning about a wrong LLVM version for every module compiled with the LLVM backend (e,g, when cross-compiling.) This PR updates the LLVM versions for these compilers to LLVM 6.
Note: ghc-8.8.1 (and presumably future ghcs in the 8.8 series) requires LLVM 7. However it appears haskell.nix does not yet support ghc-8.8.1.
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
The `overlays/ghc.nix` overrides were not applied to the `ghc` used
to by the `exactDeps` and `envDeps` `passthru` derivations. This
resulted in each ghc building twice with only one of them being cached
by hydra.
This change fixes this by moving the exactDeps and envDeps for ghc
into sub directories of the output of the ghc derivation itself.
This change moves the work done to in `envDeps` and `exactDeps`
from `make-config-files.nix` into the library components and
the `ghc` compiler component (well `passthru` derivations on the
`ghc` component).
This greatly reduces the number of times `runCommand` is
used while nix is working out what to build.
This fixes a performance regression in #323 for builds where
little or no work needs to be done. While maintaining the
performance improvement in #323 that resulted from reducing the
number of calls to `ghc-pkg` when significant work does need
to be done.
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`.
The overrides in the `ghc.nix` overlay were only applied to
`compiler.ghc865` (not `ghc`).
The fact `ghc` was not the same as `compiler.ghc865` resulted in extra
builds of ghc and a lack of caching of `haskell-nix.ghc` (used as
the default compiler by `cabalProject`).
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.
* 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).
Like `plan-nix` for `cabalProject` this gives us a way to inspect the
nix files generated by `stack-to-nix`. It may also adds `stackProject'`
that like `cabalProject'` allows us to get `stack-nix` independently of
hsPkgs (to avoid unwanted evaluation). This can be useful for caching
and preventing GC of evaluation time dependencies of the project.
Currently the haskell.nix overlays replace `haskell` and
`haskellPackages` in the root of pkgs with versions that have just a
fraction of what nixpkgs provides.
Although `haskell-nix.haskellPackages` could be used to provide a much
more complete set there are subtle differences that are likely to cause
issues (and nixpkgs has patches for many haskell packages).
To make it possible for haskell.nix and nixpkgs haskell to coexist,
we need to move the remaining parts of haskell.nix outside of the
`haskell-nix` attribute into `haskell-nix`.
```
ghc -> haskell-nix.ghc
cabal-install -> haskell-nix.cabal-install
haskell.compiler -> haskell-nix.compiler
haskell.packages -> haskell-nix.packages
bootstrap.haskell.compiler -> haskell-nix.bootstrap.compiler
bootstrap.haskell.packages -> haskell-nix.bootstrap.packages
```
The following `haskellPackages` have been removed and instead the
nixpkgs versions will now be in `haskellPackages`. User code should
be updated if the nixpkgs versions are not desired:
```
haskellPackages.hoogle
-> haskell-nix.haskellPackages.hoogle.components.exes.hoogle
haskellPackages.happy
-> haskell-nix.haskellPackages.happy.components.exes.happy
haskellPackages.alex
-> haskell-nix.haskellPackages.alex.components.exes.alex;
```
Guard code has been added to overlays/defaults.nix to prevent us
inadvertently depending on the nixpkgs `haskell` or `haskellPackages`
inside the haskell.nix code base.
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.
Projects like asterius and leksah that include dependencies on ghc. Sometimes the are needed by a setup.hs file (as is the case for the binaryen package used by asterius). The recent overlays merge broke this and #279 was needed to allow reinstallableLibGhc to be used to fix it. This PR adds a test case to make sure it is not inadvertently broken again. Also gives us a place to try out better ways to make this type of package work.* Test setup deps issue depending on ghc and Cabal
* Uses nixpkgs 19.09 + macOS wine fix on hydra/buildkite
* Enables macOS hydra tests
* disables musl tests for now
* Adds haskellNixRoots to tests
* Uses reinstallableLibGhc to fix the new setup-depends test
* Adds meta.platforms to haskell.nix components
* Set meta.platforms on cabal-install
* Builds some maintainer-scripts on hydra
* Pins hackage index-state for ghc-extra-packages
This exposes the plan nix though:
bootstrap.haskell.packages.alex-project.plan-nix
By building this on hydra you can get better errors and I think it
helps ensure cache stays populated with the dependencies needed to
build the plan.
It is also handy to be able to inspect the nix files that are
generated by plan-to-nix.
* Reorg cardano/plutus examples. Move mkCacheModule
Moves the example code from `ci.nix` into `examples/`. Also moves
`mkCacheModule` into `overlays/haskell.nix` and calls it from
stackProject.
* Fix loadArchive clang++ error on macOS
GHC 8.6.4 introduced an issue where linking to `-libc++` will cause
GHC to resolve the library path to `c++` which in turn is a link to
clang++. This results in the following error:
```
ghc: loadArchive: Neither an archive, nor a fat archive: `/nix/store/?-clang-wrapper-5.0.2/bin/clang++'
<no location info>: error:
loadArchive "/nix/store/?-clang-wrapper-5.0.2/bin/clang++": failed
```
The provided patch reverts the linking behavior of GHC to not resolve
`-libc++` to `c++`.
* Propagate unpack hooks to setup
* 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.
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
```