[commit: ghc] master: Add ways to build hadrian using nix (#473) (8fd6818)
git at git.haskell.org
git at git.haskell.org
Tue Oct 23 20:12:27 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/8fd68186b24e7fbb447401dd482e5b42f60b40f8/ghc
>---------------------------------------------------------------
commit 8fd68186b24e7fbb447401dd482e5b42f60b40f8
Author: Moritz Angermann <moritz.angermann at gmail.com>
Date: Tue Nov 21 04:06:25 2017 +0800
Add ways to build hadrian using nix (#473)
* Add ways to build hadrian using nix
This adds two new files to the hadrian directory
shell.nix sets up the build envrionment you need to build ghc
build-nix is a simple wrapper which invokes hadrian in the correct environment
Note: this patch was authored by @mpickering, however it ended up on phabricator due to the subtree as https://phabricator.haskell.org/D4207.
* Comments and renamed build-nix
>---------------------------------------------------------------
8fd68186b24e7fbb447401dd482e5b42f60b40f8
build.stack.nix.sh => build.nix.sh | 18 ++++++-----
shell.nix | 61 ++++++++++++++++++++++++++++++++++++++
2 files changed, 71 insertions(+), 8 deletions(-)
diff --git a/build.stack.nix.sh b/build.nix.sh
similarity index 66%
copy from build.stack.nix.sh
copy to build.nix.sh
index 59ac061..4b03ea8 100755
--- a/build.stack.nix.sh
+++ b/build.nix.sh
@@ -1,12 +1,9 @@
-#!/usr/bin/env bash
+#!/usr/bin/env nix-shell
+#! nix-shell -i bash shell.nix
-set -euo pipefail
+# This script sets up the build environment by invoking nix-shell shell.nix
+# and then runs the hadrian executable.
-# readlink on os x, doesn't support -f, to prevent the
-# need of installing coreutils (e.g. through brew, just
-# for readlink, we use the follownig substitute.
-#
-# source: http://stackoverflow.com/a/1116890
function rl {
TARGET_FILE="$1"
@@ -29,5 +26,10 @@ function rl {
}
absoluteRoot="$(dirname "$(rl "$0")")"
+echo $absoluteRoot
+cd "$absoluteRoot"
-HADRIAN_NIX=YES ${absoluteRoot}/build.stack.sh
+hadrian \
+ --lint \
+ --directory="$absoluteRoot/.." \
+ "$@"
diff --git a/shell.nix b/shell.nix
new file mode 100644
index 0000000..e9a5ecc
--- /dev/null
+++ b/shell.nix
@@ -0,0 +1,61 @@
+# Invoking nix-shell sets up an environment where we can build ghc
+# by only invoking hadrian.
+
+
+{ nixpkgs ? import <nixpkgs> {} }:
+
+let
+ haskellPackages = nixpkgs.haskell.packages.ghc821;
+
+ removeBuild = path: type:
+ let baseName = baseNameOf (toString path);
+ in
+ ! (baseName == "_build"
+ || baseName == "dist"
+ || baseName == "dist-newstyle"
+ || baseName == ".stack-work"
+ || baseName == "config.log"
+ || baseName == "config.status"
+ || nixpkgs.lib.hasSuffix ".sh" baseName
+ || !(nixpkgs.lib.cleanSourceFilter path type)) ;
+
+ filterSrc = path: builtins.filterSource removeBuild path;
+
+
+ hadrianPackages = nixpkgs.haskell.packages.ghc821.override {
+ overrides = self: super: let
+ localPackage = name: path: self.callCabal2nix name (filterSrc path) {};
+ in {
+ hadrian = localPackage "hadrian" ./. ;
+ shake = self.callHackage "shake" "0.16" {};
+ Cabal = localPackage "Cabal" ./../libraries/Cabal/Cabal ;
+ filepath = localPackage "filepath" ./../libraries/filepath ;
+ text = localPackage "text" ./../libraries/text ;
+ hpc = localPackage"hpc" ./../libraries/hpc ;
+ parsec = localPackage "parsec" ./../libraries/parsec ;
+ HUnit = nixpkgs.haskell.lib.dontCheck (self.callHackage "HUnit" "1.3.1.2" {});
+ process = localPackage "process" ./../libraries/process ;
+ directory = localPackage "directory" ./../libraries/directory ;
+ }; };
+
+in
+
+ nixpkgs.stdenv.mkDerivation {
+ name = "ghc-dev";
+ buildInputs = [
+ hadrianPackages.hadrian
+ nixpkgs.haskell.compiler.ghc821
+ haskellPackages.alex
+ haskellPackages.happy
+ nixpkgs.python3
+ nixpkgs.git
+ nixpkgs.autoconf
+ nixpkgs.automake
+ nixpkgs.perl
+ nixpkgs.gcc
+ nixpkgs.python3Packages.sphinx
+ nixpkgs.ncurses
+ nixpkgs.m4
+ nixpkgs.gmp
+ nixpkgs.file ];
+ }
More information about the ghc-commits
mailing list