haskell.nix/build.nix

102 lines
4.7 KiB
Nix
Raw Normal View History

# This file contains the package set used by the release.nix jobset.
#
# It is separate from default.nix because that file is the public API
# of Haskell.nix, which shouldn't have tests, etc.
let
haskellNix = (import ./default.nix {});
in
{ nixpkgs ? haskellNix.sources.nixpkgs-2111
, nixpkgsArgs ? haskellNix.nixpkgsArgs
, pkgs ? import nixpkgs nixpkgsArgs
, evalPackages ? import nixpkgs nixpkgsArgs
, nixpkgsForHydra ? haskellNix.sources.nixpkgs-2105
, pkgsForHydra ? import nixpkgsForHydra (nixpkgsArgs // { inherit (pkgs) system; })
, ifdLevel ? 1000
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 13:54:01 +03:00
, compiler-nix-name ? throw "No `compiler-nix-name` passed to build.nix"
}:
let
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 15:07:58 +03:00
haskell = pkgs.haskell-nix;
buildHaskell = pkgs.buildPackages.haskell-nix;
tool = buildHaskell.tool;
in rec {
tests = import ./test/default.nix { inherit pkgs evalPackages ifdLevel compiler-nix-name; };
tools = pkgs.lib.optionalAttrs (ifdLevel >= 3) (
pkgs.recurseIntoAttrs ({
cabal-latest = tool compiler-nix-name "cabal" { inherit evalPackages; };
hlint-latest = tool compiler-nix-name "hlint" {
inherit evalPackages;
version = {
"ghc865" = "3.2.8";
"ghc882" = "3.3.6";
"ghc883" = "3.3.6";
"ghc884" = "3.3.6";
}.compiler-nix-name or "latest";
};
2022-07-31 12:41:50 +03:00
} // pkgs.lib.optionalAttrs (!__elem compiler-nix-name ["ghc921" "ghc922" "ghc923" "ghc924"]) {
hls-latest = tool compiler-nix-name "haskell-language-server" { inherit evalPackages; };
})
);
# Scripts for keeping Hackage and Stackage up to date, and CI tasks.
# The dontRecurseIntoAttrs prevents these from building on hydra
# as not all of them can work in restricted eval mode (as they
# are not pure).
maintainer-scripts = pkgs.dontRecurseIntoAttrs {
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 13:54:01 +03:00
update-hackage = import ./scripts/update-hackage.nix {
inherit (pkgs) stdenv lib writeScript coreutils glibc git
openssh nixFlakes gawk bash curl findutils;
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 13:54:01 +03:00
# Update scripts use the internal nix-tools and cabal-install (compiled with a fixed GHC version)
nix-tools = haskell.internal-nix-tools;
cabal-install = haskell.internal-cabal-install;
inherit (haskell) update-index-state-hashes;
};
update-stackage = haskell.callPackage ./scripts/update-stackage.nix {
inherit (pkgs) stdenv lib writeScript coreutils glibc git
openssh nixFlakes gawk bash curl findutils;
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 13:54:01 +03:00
# Update scripts use the internal nix-tools and cabal-install (compiled with a fixed GHC version)
nix-tools = haskell.internal-nix-tools;
cabal-install = haskell.internal-cabal-install;
};
update-pins = haskell.callPackage ./scripts/update-pins.nix {};
update-docs = pkgs.buildPackages.callPackage ./scripts/update-docs.nix {
generatedOptions = pkgs.callPackage ./scripts/options-doc.nix { };
};
# Because this is going to be used to test caching on hydra, it must not
# use the darcs package from the haskell.nix we are testing. For that reason
# it uses `pkgs.buildPackages.callPackage` not `haskell.callPackage`
# (We could pull in darcs from a known good haskell.nix for hydra to
# use)
check-hydra = pkgsForHydra.buildPackages.callPackage ./scripts/check-hydra.nix {};
check-closure-size = pkgs.buildPackages.callPackage ./scripts/check-closure-size.nix {
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 13:54:01 +03:00
# Includes cabal-install since this is commonly used.
nix-tools = pkgs.linkFarm "common-tools" [
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 13:54:01 +03:00
{ name = "nix-tools"; path = haskell.nix-tools.${compiler-nix-name}; }
{ name = "cabal-install"; path = haskell.cabal-install.${compiler-nix-name}; }
];
};
check-materialization-concurrency = pkgs.buildPackages.callPackage ./scripts/check-materialization-concurrency/check.nix {};
check-path-support = pkgs.buildPackages.callPackage ./scripts/check-path-support.nix {
# TODO remove this when nixpkgs-2205 is released and used for `pkgs`
# check-path-support fails unless we have nix 2.4 or newer.
inherit (import haskellNix.sources.nixpkgs-unstable {}) nix;
};
};
# These are pure parts of maintainer-script so they can be built by hydra
# and added to the cache to speed up buildkite.
maintainer-script-cache = pkgs.recurseIntoAttrs (
(pkgs.lib.optionalAttrs (pkgsForHydra.system == "x86_64-linux") {
inherit (maintainer-scripts) check-hydra;
})
// (pkgs.lib.optionalAttrs (ifdLevel > 2) {
inherit (maintainer-scripts) update-docs check-closure-size;
# Some of the dependencies of the impure scripts so that they will
# will be in the cache too for buildkite.
inherit (pkgs.buildPackages) glibc coreutils git openssh cabal-install nix-prefetch-git;
inherit (haskell) nix-tools;
})
);
}