Commit Graph
51 Commits
Author SHA1 Message Date
Hamish Mackenzie 4b2b460080 Bump haskell.nix used in nix-tools flake (#1709) 2022-09-24 20:30:00 +12:00
Yvan SrakaandHamish Mackenzie 5990fee152 Fix #1674: use Nix flakes rather than Niv to pin nix-tools dependencies (#1694)
* Fix #1674: use Nix flakes rather than Niv to pin `nix-tools` dependencies

* Update nix-tools flake

* Update nix-tools flake.lock

* Update nix-tools flake.nix

* Update nix-tools flake.lock

* Update materialization

* Update materialization

* Update nix-tools flake.lock

Co-authored-by: Hamish Mackenzie <Hamish.K.Mackenzie@gmail.com>
2022-09-24 18:39:55 +12:00
Yvan Sraka e167653461 Fix #1672: migrate nix-tools/.buildkite into .buildkite (#1695) 2022-09-20 20:56:48 +12:00
Andrea Bedini 5b7f7f245c Add 'nix-tools/' from commit '555d57e1ea81b79945f2608aa261df20f6b602a5'
git-subtree-dir: nix-tools
git-subtree-mainline: 1110a74a9d
git-subtree-split: 555d57e1ea
2022-09-15 08:11:42 +02:00
Rodney LorrimarandHamish Mackenzie d6e47d8b50 Bump nix-tools to latest master (#955)
* Bump nix-tools to latest master

* Add docs for checking nix-tools materialization

Co-authored-by: Hamish Mackenzie <Hamish.Mackenzie@iohk.io>
2020-12-03 22:53:15 +13:00
John A. Lotoski 09526c8555 Spelling, typo and whitespace fixes (#833)
* Spelling and typo fixes in doc and code comments
* Trailing whitespace or whitespace only truncation
* readTheDocs formatting corrections
2020-08-31 11:08:25 +12:00
Hamish Mackenzie cacfba0b45 Replace ghc 8.8.3 with 8.8.4 (#766)
Also adds some tooling/docs for adding new ghc versions (see `docs/adding-new-ghc.md`)
2020-07-21 14:10:23 +12:00
Hamish Mackenzie 4cac8bd00f Remove internal deps on default ghc and stackage (#738)
Changes to the interface of haskell.nix (from the changelog.md file):

* Removed `sources.nixpkgs-default`, use `sources.nixpkgs` instead.
* Removed `./nixpkgs` directory, use  `(import ./. {}).sources`
  or `./nix/sources.nix` instead.
* Removes V1 interface for details on how to fix old code see:
    https://github.com/input-output-hk/haskell.nix/issues/709
* Removed defaultCompilerNixName.
* cabalProject, cabalProject', hackage-project and hackage-package
  now require a `compiler-nix-name` argument.
* `haskell-nix.tool` and `.tools` now require a `compiler-nix-name` argument.
  New functions `p.tool` and `p.tools` (where p is a project) do not.
  Like `shellFor { tools = ... }` they will use the compiler nix name
  from the project (including stack projects where it is derived from
  the resolver).
* `haskell-nix.alex` and `haskell-nix.happy` have been removed. Use
  `p.tool "alex" "3.2.5"` or `shellFor { tools = { alex = "3.2.5"; } }`.
* `haskell-nix.nix-tools` -> `haskell-nix.nix-tools.ghc883` (it includes
  the hpack exe now).
* `haskell-nix.cabal-install` -> 
  `p.tool "cabal" "3.2.0.0"` or `shellFor { tools = { cabal = "3.2.0.0"; } }`
* `haskell-nix.haskellNixRoots` -> `haskell-nix.roots ghc883` or `p.roots`

Other changes:

Adds hpack executable to the nix-tools derivations.

Adds a `cabal-hpack` test to make sure `hpack` works with
`cabalProject`.

Reduces the number of calls to `cabalProject` (particularly when
checking materialization), by giving internal tools a per-compiler
attribute.

Uses happy 1.19.12 when building newer ghc versions.

Updates cabal-install 3.2.0.0 to use the source from github that
is compatible with ghc 8.10.1.

Updates the docs for callCabalProjectToNix.

Adds a license mapping to fix a common warning.
2020-07-08 22:54:01 +12:00
Hamish MackenzieandRodney Lorrimar 8cbf979538 Add nix-tools to niv and update docs to fix #675 (#678)
* Updates docs/user-guide.md

Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
2020-06-15 14:36:05 +12:00
Hamish Mackenzie 80e0e61a81 Fix arm cross compilation with ghc 8.6.5 (#654) 2020-06-06 13:32:09 +12:00
Travis WhitakerandMoritz Angermann ed673956e8 Native aarch64 support (#620)
* native aarch64 support

Co-authored-by: Moritz Angermann <moritz.angermann@gmail.com>
2020-06-04 20:29:50 +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
Hamish Mackenzie 39d4ac6856 Include nix-tools/pull/90 (#601) 2020-05-13 08:19:00 +08:00
Hamish Mackenzie 5e276a6a10 Fix hackage cabal revisions attempt 2 (#600)
* Revert "Update Hackage and Stackage"

This reverts commit 566d63bc01.

* Fix file missed hackage-db.nix update

* Remove `*` from message in case it confuses others

Copying with `*` leaves out `.plan.nix`
2020-05-13 07:25:57 +08:00
Hamish Mackenzie cab6f7c2b7 Fix hackage-to-nix missing old hackage revisions (#597) 2020-05-12 20:44:58 +12:00
Maxim KoltsovandHamish Mackenzie fea02bdaba Update nix-tools with Cabal-3.2 (#591)
Update nix-tools and regenerate nix-tools plan

Co-authored-by: Hamish Mackenzie <Hamish.Mackenzie@iohk.io>
2020-05-11 23:54:13 +12:00
Michael Peyton Jones eb15db0450 Expose our nixpkgs pins by restructuring default.nix (#514)
* Remove unused (and broken) test files

* Make default.nix expose pinned nixpkgs

Also make `nixpkgs/default.nix` just an attribute set of sources.
This is simpler, and consistent with what e.g. `niv` does.

* Add backwards compatibility shim, and version argument to allow evolution in future

* Fix some missed things

* Fix and improve quickstart
2020-03-31 09:12:40 +08:00
Moritz Angermann 068714dbfe bump nix-tools 2020-03-24 12:51:31 +08:00
Moritz Angermann 4686c646c0 bump nix-tools 2020-03-07 21:08:50 +08:00
Moritz Angermann ae8e4e38ef bump nix tools (#476)
Bumps nix tools, and add regen logic. Also fixes happy at 1.19.9
2020-03-06 17:19:45 +08:00
Hamish MackenzieandHideaki KAWAI 122bd81150 Add ghc 8.8.1 to the supported compilers (#342)
* 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>
2020-02-04 15:19:37 +08: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
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
Yorick 00d61f7d3f Update nix-tools (fixes #309) (#343) 2019-12-03 15:49:31 +08: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
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 df51ce67b2 Fix conflicting flag definitions #254 (#258) 2019-10-13 19:42:26 +08:00
Hamish Mackenzie 147cf21341 Add ghcOptions on packages (#257)
* Add `ghcOptions` with example and docs
2019-10-13 14:19:59 +08:00
Hamish Mackenzie f648a6585e Fix project flags (#253)
Project flags (from stack.yaml and plan.json) are exported in a modules attribute by stack-to-nix and plan-to-nix, but are not currently used. This change updates `mkStackPkgSet` and `mkCabalProjectPkgSet` so that the modules attribute is used (if present) and includes tests to check they are.

This commit makes `stdenv.lib.mkOverride` necessary for setting flags in `mkCabalProjectPkgSet` modules, however it also means that you can set them in `cabal.project` instead (see #254).
2019-10-11 17:19:31 +13: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 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
Moritz Angermann 9643221e6f Add comment regarding wrapping of -to-nix exes (#208) 2019-07-16 13:03:37 +10:00
Hamish Mackenzie efab350c0f Fix setup-depends dependencies (#124)
* Use setup-depends from nix-tools output

* Use `-package ghc` when building Setup.hs

* Include --package-db when building Setup

* Fix for tests on case insensitive FS (macOS)

The file `conduit.hs` looks like `Conduit.hs` to ghc and it uses it
by mistake for `import Conduit`.
2019-07-12 21:48:13 +08:00
Rodney Lorrimar 3bb58214f1 Add cross-compiled musl libc builds of tests (#157)
* Add cross-compiled musl libc builds of tests

* Bump nixpkgs to latest 19.03

* tests: Update stack-simple LTS

* docs: Add note about tests

* Regenerate tests

* haskellPackages: lts-13.18 -> lts-13.26

This contains GHC 8.6.5 which can successfully build under
pkgsCross.musl64, whereas GHC 8.6.4 could not.

* Bump nix-tools

* Regenerate nix-tools -- changed compiler from GHC 8.6.4 -> GHC 8.6.5.
2019-07-02 18:25:40 +10:00
Rodney Lorrimar 2e49d28de0 Reduce closure size of nix-tools (#178)
* Buildkite: Add a test for nix-tools closure size

The limit is a rather generous 500MB.

* nix-tools: Reduce closure size

1. Run justStackExecutables on hpack to remove dependency on ghc and
   libraries.

   Ideally we would be using the component builder on hpack.

2. Replace nix-prefetch-scripts with nix-prefetch-git. stack.yaml
   supports mercurial repositories but I've never seen it used.
2019-06-15 07:18:06 +02:00
Rodney Lorrimar 7d94fe2ef5 Revert "Update nix-tools version (#174)"
This reverts commit cd810e5094.

The stack-to-nix flags generation is not correct yet.
2019-06-13 14:48:54 +10:00
Rodney Lorrimar cd810e5094 Update nix-tools version (#174) 2019-06-13 12:52:12 +10:00
Rodney Lorrimar caf1f61267 Use release-lib.nix for Hydra (#161)
* Use release-lib.nix for Hydra jobset

* Buildkite: Add a script to check Hydra evaluation
2019-06-03 11:26:28 +08: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
Moritz Angermann 2d54f2c303 Use pkgs.fetchurl to build a fixed output derivation (#145)
* Use pkgs.fetchurl to build a fixed output derivation

This should hopefully get us around the restricted limitations.

* Adds asserts

* Fix index-state-hashes file

* Fix index-state-hashes

Also adds a regeneration tool:

```
nix build -f ./. generateHackageIndexStateHashes
cp result lib/index-state-hashes.nix
```

* Fix off-by-one

* better errors
2019-05-23 13:13:04 +08:00
Hamish Mackenzie 3d1c8afcde Add cleanSourceHaskell and use it on nix-tools (#144)
Currently if you override nix-tools using `-I nix-tools` to point to
a local directory that has build output directories like `dist-newstyle`
those directories are hashed and copied to the nix store if they have
changes.  This change adds the `cleanHaskellSource` function from
`iohk-nix` and runs it on nix-tools.
2019-05-22 11:14:12 +08:00
Moritz Angermann e5d4c820c5 Update nix-tools expression (#139) 2019-05-20 22:44:16 +08:00
Moritz Angermann d99a7ad274 Bump nix-tools (#132) 2019-05-18 14:33:21 +08:00
Moritz Angermann ec226247d2 Bump nix-tools (#111)
This includes the changes that quote pkg-config packages properly.
2019-05-07 15:35:28 +08:00
Moritz Angermann aa4dbaa972 Fix flags
This should have been set by `plan-to-nix`.
2019-04-02 21:18:02 +08:00
Rodney Lorrimar adf6b4385b Put back src for nix-tools 2019-04-02 20:18:38 +10:00
Rodney Lorrimar d416f60714 nix-tools: Add overrides for -compat libraries 2019-04-02 20:12:22 +10:00
Rodney Lorrimar 4478c67f3a Bring nix-tools build into haskell.nix
I plan to delete the auto-generated nix expressions in nix-tools so
that it is a pure cabal project.
2019-04-02 12:34:08 +10:00
Rodney Lorrimar a9f0250f28 Bump nix-tools rev 2019-03-20 12:43:10 +10:00