Commit Graph

30 Commits

Author SHA1 Message Date
Yvan Sraka 8309423b1a Fix #518: examples in documentation need to be tested (#1714) 2022-10-06 10:36:38 +02:00
Jean-Baptiste Giraudeau b66b0445eb Allows project to be easily extended. (#1467)
* Allows project to be easily extended.

* Add common project overlays
2022-05-13 21:21:19 +12:00
Jean-Baptiste Giraudeau 749a7dc068 Add appendModule function to projects. (#1240)
Allow re-eval of the project with an extra module (or module list).
2021-09-18 14:43:46 +12:00
Hamish Mackenzie 91adf5f97d Add crossPlatforms arg to shellFor (#1089)
This makes it easier to get cross compilers for a project in a nix shell.
2021-04-16 17:50:10 +12:00
Hamish Mackenzie a9584f36e2 Add projectCross to projects (like pkgsCross) (#946)
This change adds a `projectCross` attribute to the return value of
the project functions.  It is similar to `pkgs.pkgsCross` and makes
it easier to build cross compiled versions of project (or get
a cross compile with `p.projectCross.${platform}.shellFor`).
2020-11-30 15:42:05 +13:00
Hamish Mackenzie c0931c9a56 Replace otherShells with mkShell inputsFrom (#939)
It turns out the `otherShells` arg we added to `shellFor` is very
similar to the `inputsFrom` argument of `mkShell`.  We can use
`inputsFrom` instead having `otherShells` by replacing the use of
`mkDerivation` with `mkShell` in `shellFor`.
2020-11-26 21:15:27 +13:00
Hamish Mackenzie 5df5be0d08 Remove pj.hsPkgs.${n} functions in favour of pj.${n} (#938)
Applies to:

 * makeConfigFiles
 * ghcWithHoogle
 * ghcWithPackages
 * shellFor
2020-11-26 19:20:10 +13:00
Hamish Mackenzie e729389f32 Add otherShells arg to shellFor (#937)
Makes it easier to include cross compilation shells.  The
buildInputs and nativeBuildInputs of the shells are added.
2020-11-24 16:28:45 +13:00
Eric Wolf 0c3abc8a6d Allow for hoogle to be materialized in shellFor (#902)
Allow for hoogle to be materialized in `shellFor` by using `tools.hoogle` when passed in.

Co-authored-by: Hamish Mackenzie <Hamish.K.Mackenzie@googlemail.com>
2020-10-31 20:46:54 +13:00
Hamish Mackenzie b6de6ef3b8 Remove components.all (#776)
It causes a lot of issues. To make this work:

* `shellFor` is updated to use `getAllComponents` instead of `.all`.
* `getAllComponents` is updated to work on the package rather than
  the package config.
* Tests updated to not use `.library` or `.exes.X` where appropriate.
* Documentation updated.
* Out of date examples removed.

As a bonus `shellFor` now takes a `components` argument that might be
useful for limiting the dependencies of the shell to just the ones
needed for the components you intend to work on.
2020-07-21 16:06:54 +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
Domen Kožar 8b79a284e7 more typos (#757) 2020-07-10 11:46:08 +08:00
Domen Kožar 1d6ad76ffe fix internal links for *project reference (#756) 2020-07-09 11:48:22 +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
Domen Kožar 33445e4fb9 Add project, cabalProject, stackProject references (#753)
* Add project, cabalProject, stackProject references

* Update docs/reference/library.md

Co-authored-by: Moritz Angermann <moritz.angermann@gmail.com>

Co-authored-by: Moritz Angermann <moritz.angermann@gmail.com>
2020-07-08 21:25:24 +12:00
Domen Kožar 2852a9521f Reorganize tutorials (#702)
* fix hackage and stackage to work

* user-guides -> tutorials

* Restructure tutorials

* getting-started: clarify on packages and components

* Update docs/tutorials/development.md

Co-authored-by: Rodney Lorrimar <dev@rodney.id.au>

* getting-started: bail out if cabal.project and stack.yaml are present

* hackage-stackage: delete duplicated content

Co-authored-by: Rodney Lorrimar <dev@rodney.id.au>
2020-06-19 13:37:02 +12: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
Michael Peyton Jones 614a675330 Add collectChecks functions (#498)
Fixes #482.
2020-03-20 19:34:40 +13: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
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
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 26d7b00f1d Custom args to cabal new-configure IFD functions (#305) 2019-11-08 17:53:05 +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
Rodney Lorrimar b47a6bb1a2 shellFor: Use CABAL_CONFIG only with exactDeps = true (#255)
* shellFor: Use CABAL_CONFIG only with exactDeps = true

* shells: Put write-ghc-environment-files: never in cabal.config
2019-10-13 19:43:17 +08:00
Rodney Lorrimar ad640fa02d docs: Add note about shellFor and CABAL_CONFIG (#247) 2019-09-24 08:53:20 +10: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
Rodney Lorrimar e15f235319 More documentation (#179)
* docs: Fix notes about .nix-tools.cache

Relates to #57

* docs: Add note about Cabal 2.4 requirement

Fixes #164

* docs: Autogenerate module option reference

* docs: Update library reference

* Buildkite: enable docs build on branches
2019-06-15 07:11:52 +02:00
Rodney Lorrimar b4b18edeec Docs improvements (#171)
- Dev note about nixpkgs pin
- More information about selecting a GHC version for cabal projects
- A little bit more information about cross compiling, but this is still incomplete.
2019-06-12 10:18:38 +10:00
Rodney Lorrimar 3747f54357 Update the docs (#165)
The docs are not complete yet, but we can start improving them from here.
2019-06-07 14:46:44 +10:00