Commit Graph

39 Commits

Author SHA1 Message Date
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 Koltsov
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 Mackenzie
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
Rodney Lorrimar
72cc37dcc3
Add nix-tools 2019-02-13 14:51:10 +10:00