Commit Graph

40 Commits

Author SHA1 Message Date
Hamish Mackenzie db3e7e6ccb Remove unused problematic input nix-tools (#1736) 2022-10-05 13:57:55 +13:00
Yvan Sraka 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
Hamish Mackenzie c784d65a60 Add nix develop github:input-output-hk/haskell.nix#ghcXXX (#1699)
* Add `nix develop github:input-output-hk/haskell.nix#ghcXXX`

As a quick way to get a shell with ghc and cabal.

* Exclude old versions of GHC to speed up `nix flake check`
2022-09-19 20:25:45 +12:00
Andrea Bedini 05c20120f5 Rewire nix-tools 2022-09-15 08:12:03 +02:00
Hamish Mackenzie d68d847949 Bump flake-compat to latest iohk version (#1655)
* Bump flake-compat to latest iohk version

* Fix nix-shell
2022-09-12 14:38:40 +12:00
Hamish Mackenzie c683efad28 Bump nixpkgs pin used in default.nix (#1649)
* Bump nixpkgs pin used in default.nix

Making it match the current 22.05 pin in flake.lock.

Was going to do this because of #1648, but might save some people a nixpkgs download so let's do it anyway.

* Fix test issue

* Use flake.lock

* Use flake.lock
2022-09-09 18:23:46 +12:00
Yvan Sraka 0f2bd4e7f3 Fix flake devShell (thanks to @hamishmack patch) (#1624) 2022-08-29 10:53:14 +00:00
Yvan Sraka ca80ad0156 Add IOG nix cache in flake configuration (#1579)
From https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html#flake-format

> `nixConfig`: a set of `nix.conf` options to be set when evaluating any part of a flake. In the interests of security, only a small set of whitelisted options (currently `bash-prompt`, `bash-prompt-prefix`, `bash-prompt-suffix`, and `flake-registry`) are allowed to be set without confirmation so long as `accept-flake-config` is not set in the global configuration.
2022-08-27 17:24:55 +12:00
Yvan Sraka 3c9acea8fe Fix #1581 & #1586: flake output attribute 'defaultPackage' and 'devShell' are deprecated (#1583)
Using 'packages.<system>.default' and 'devShells.<system>.default' instead
2022-08-18 08:01:52 +00:00
Hamish Mackenzie 05c0555400 Add flake support to hix (#1572)
This adds support for using nix flakes commands with hix.  This is done by creating a hidden `.hix-flake` directory and passing the source in using `--override-input`.

It also includes a `hix init` command to add a `flake.nix` and `nix/hix.nix` configuration file.
2022-08-05 10:17:16 +12:00
Hamish Mackenzie c2f14344f1 Add ghc 9.2.4 (#1566) 2022-07-31 21:41:50 +12:00
Hamish Mackenzie a443611ecf Add evalSystem and evalPackages project args (#1546)
This adds a way to specify the `evalSystem` or `evalPackages` explicitly when calling the `project` functions.

Currently if we want to make a `flake` that supports multiple systems we have few options:

* Require builders for all the supported systems (even just for `nix flake show`).

* Pass `--impure` so that haskell.nix can see `builtins.currentSystem` to set up `pkgs.evalPackages` to use that.  Unfortunately this prevents nix from caching some of the work it does and often results in it recalculating for each supported system when it would otherwise be cached and take no time at all.

* Add an overlay to replace `evalPackages`.  This works, but it is not straight forward.

* Materialize the nix files for the project.

This change allows `evalSystem = "x86_64-linux";` to be passed telling `haskell.nix` to run `cabal` and `nix-tools` on that system.  The user will have to have a builder for that system, but does not need to have builders for the others (unless building outputs for them).
2022-07-28 20:03:05 +12:00
Hamish Mackenzie 4e01f34543 Add nixpkgs-2205 and update other nixpkgs pins (#1506) 2022-07-17 18:18:19 +12:00
Hamish Mackenzie 91036142ef Better support for allow-import-from-derivation=false (#1474)
Currently haskell.nix uses IFDs internally in a number of places.  This prevents the use of `--option allow-import-from-derivation false` even when `materialized` nix is provided.

* Changes `materialize` function so that it returns the `materialized` path when possible instead of a derivation (updates import-and-filter-project.nix to cope with that).
* Materializes the spdx json file.
* Prevents haskell.nix looking for `cabal.project`, `cabal.project.local` and `cabal.project.freeze` files in hackage packages and the ghc-extra-projects.
2022-06-02 20:11:27 +12:00
DavHau 1ca99326b2 always clean the source, no matter what (#1403)
* always clean the source, no matter what

* update hydra
2022-03-19 02:08:11 +13:00
Hamish Mackenzie 41682ea1fd update pins (#1371) 2022-02-15 11:11:34 +13:00
Moritz Angermann eb7e669d63 Enable aarch64 builds (#1316)
* Adds small address space logic

* no numa on android

* Update comp-builder.nix

* Adds android.nix

* host And target.

* Make android remote-iserv static

* Add back mmap_next

* Create rts-android-jemalloc-qemu.patch

* Update bootstrap.nix

* Some android modifications to ghc

* Some modifications to the android overlay.

* disable more hardening flags on android

* Adds stack-protector-symbols.patch

* Adds libraries-prim-os-android.patch

* Adds support for CONDBR relocations

* Adds undef+weak symbol support.

* calloc takes 3 not 2 args :-(

* Adds getauxval

* Needs enable static now

* Fix android cross
2022-01-09 11:36:53 +13:00
Peter Becich 4e1d9f229c update flake.nix for Cabal 3.6 (#1324)
https://github.com/haskell/cabal/tree/3.6
2021-12-31 09:46:22 +08:00
Tom Prince a68a7dda41 Add nixos-21.11 builds. (#1304)
* Add nixos-21.11 builds.

* Remove references to nixpkgs-20.09.
2021-12-07 12:55:20 +13:00
Hamish Mackenzie 19052d83fd Expose config.nix for flakes to use (#1238) 2021-09-15 23:00:14 +12:00
Hamish Mackenzie f3b109b2fb Add aarch64-darwin support (#1230) 2021-09-07 22:22:01 +12:00
Jean-Baptiste Giraudeau ba9346d501 Bump nixos-21.05 pin (bintools import fix) and use as default. (#1229) 2021-09-04 16:15:31 +12:00
Shea Levy 1729233076 Fix non-flake compatibility layer. (#1204)
Previously 'overlays' was being taken from the non-compat flake output
and nixpkgsArgs referenced the wrong version.

Fixes #1192
2021-08-16 13:08:42 +01:00
Hamish Mackenzie d5d304d5b5 Flakify all inputs (#1180)
* Include dependencies of haskell.nix that were tracked in `nix/sources.json`
  as flake inputs (`flake.lock` replaces `nix/sources.json`).
* Use `flake-compat` to continue to provide a compatible interface for non
  flake projects.

Co-authored-by: Alexander Bantyev <balsoft@balsoft.ru>
Co-authored-by: Shea Levy <shea@shealevy.com>
2021-08-06 15:54:39 +12:00
Jean-Baptiste Giraudeau 531c9f4cac Remove some flake specifics that can mess-up caching. (#1176)
* Remove flake specific sourceOverride that mess-up caching.

* Reduce evalPackages discrepency between flake/non-flake.

* Remove dependency on <nixpkgs> when importing sources.nix
2021-07-28 12:38:03 +12:00
Hamish Mackenzie 61e89b7df5 Simplify the way evalPackages works (#1162)
This change uses the same overlay for both flakes and non flake projects.  It chooses where evalPackages should run based on `builtins ? currentSystem` (`currentSystem` will not exist when building flake).

This will be needed to make sure the `evalPackages` still works correctly in #1151 (otherwise the use of `flake-compat` will cause eval-on-build to be used).
2021-07-07 22:43:19 +12:00
Hamish Mackenzie 4f5755ce99 Update nixpkgs pins in flake.nix based on sources.json (#1147) 2021-06-24 12:46:04 +12:00
Hamish Mackenzie c3841b4208 Add cross compilation and devShell to project.flake (#1141)
The default shell `devShell` works by adding a default `shell` to all projects.  You can pass the shell arguments to the project function using the new `shell` argument:

```
let myProject = haskell-nix.project {
  src = ./.;
  shell.tools = { cabal = {}; };
  shell.crossPlatforms = p: [ p.cross ];
};
```

This will include js-unknown-ghcjs-cabal in the `devShell`.

To add cross compiled outputs to the flake pass `crossPlatforms` to the `flake` function.

```
myProject.flake { crossPlatforms = p: [ p.cross ]; }
```

To cross compile a component include the platforms `config` string to the output name like this

```
nix build .#js-unknown-ghcjs:pkg-name:lib:pkg-name
```
2021-06-17 19:07:37 +12:00
Hamish Mackenzie 172d402394 Add more flakes support and getting started guide (#972)
This PR adds a `flake` function to haskell.nix projects.  It can
be used to transform the outputs of project into a flattened structure
that can be used to make a `flake.nix` file for your project.

Because the nix code and commands used are different a lot of stuff in
the getting-started.md will not work with a `flake.nix`.  So instead
of trying to add a flake section to that guide this PR adds a new
version for Nix Flake users.
2021-02-22 20:42:33 +13:00
Alexander Bantyev fd44431a92 flake: export internal functions for more flexibility (#1017)
As of d014079 (#953), haskell.nix internals (such as unapplied
./overlays, sources, etc) are not exported in flake.nix. This makes
it harder to override things when using haskell.nix as a flake.

The use-case I have in mind is to pin haskell.nix itself to prevent
unnecessary GHC rebuilds/redownloads and update only
hackage&stackage. This could be done with a following overlay:

    (haskell-nix.overlays {
      sourcesOverride = haskell-nix.sources // {
        inherit hackage stackage;
      };
    }).combined-eval-on-build

However, this is not the case as of the aforementioned commit. Now, to
do this one has to import ./nix/sources.json, reimplementing what's
already done in haskell.nix, and also import ./overlays. With this
commit, previous snippet turns into the following:

    (haskell-nix.internal.overlaysOverrideable {
      sourcesOverride = haskell-nix.internal.sources // {
        inherit hackage stackage;
      };
    }).combined-eval-on-build

`nix flake check` will now warn us of "unknown flake output
'internal'", but I think it is fine (e.g. nixpkgs has an unknown flake
output as well)
2021-02-22 19:11:58 +13:00
Hamish Mackenzie 180779b7f5 Fix issue with self. in flake (#959) 2020-12-04 20:13:56 +13:00
Hamish Mackenzie 790c3f9124 Fix issue with self.sources in flake (#958) 2020-12-04 19:09:30 +13:00
Hamish Mackenzie d014079cce Fix nix flake check warnings (#953) 2020-12-02 22:31:09 +13:00
Ninjatrappeur 36649ab403 flake: remove outdated edition field. (#912)
The flake edition attribute has been deprecated and removed from Nix.

See:
- https://github.com/NixOS/nix/commit/e5ea01c1a8bbd328dcc576928bf3e4271cb55399
- https://github.com/NixOS/nix/commit/b875b8f45c8d73c26e2cf13843fa25cc6762eebc
2020-11-06 17:18:43 +00:00
Julien Moutinho a8f5fed74b Fix #824 (#824) (#832)
Co-authored-by: Julien Moutinho <julm+haskell.nix@sourcephile.fr>
2020-08-31 21:05:09 +12:00
Alexander Bantyev afbb245fa8 Fix flake by importing sources correctly (#797) 2020-08-04 17:26:56 +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
Tony O c7e6531d2c Fix flake overlay attr (#684)
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
2020-06-14 18:30:30 +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 a2d97bd9ad Flake (#589 and #567)
Allows haskell.nix to be used as a nix flake.

Authored-by: Alexander Bantyev <balsoft@balsoft.ru>
2020-05-07 11:16:38 +12:00