This repository has been archived by the owner on Feb 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
build.nix
69 lines (61 loc) · 2.52 KB
/
build.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
{ ghcVersion, glibcName }:
let
sources = import ./sources.nix;
pkgs = sources.glibcSpecificPkgs.${glibcName} or (throw "all-hies: A nixpkgs with ${glibcName} is currently not supported. ");
inherit (pkgs) lib;
versionList = builtins.match "([0-9]+)\\.([0-9]+)\\.([0-9]+)" ghcVersion;
version = rec {
major = lib.elemAt versionList 0;
minor = lib.elemAt versionList 1;
patch = lib.elemAt versionList 2;
dotVersion = "${major}.${minor}.${patch}";
tightVersion = "${major}${minor}${patch}";
};
supportedVersions = [ "8.6.5" "8.8.3" ];
unsupportedWarning = if lib.elem ghcVersion supportedVersions then lib.id else lib.warn "all-hies: GHC version ${ghcVersion} is not supported, no caches are available and the build will probably fail";
stackArgs = {
src = sources.hie.src;
stackYaml = "stack-${version.dotVersion}.yaml";
# TODO: Remove GHC from closure
modules = [{
reinstallableLibGhc = true;
doHaddock = false;
packages.ghc.flags.ghci = true;
packages.ghci.flags.ghci = true;
packages.haskell-ide-engine.configureFlags = [ "--enable-executable-dynamic" ];
}];
};
generatedDir = ./generated + "/${version.dotVersion}";
hashFile = generatedDir + "/stack-sha256";
materializedDir = generatedDir + "/materialized";
materializedStackArgs = stackArgs // lib.optionalAttrs (builtins.pathExists generatedDir) {
stack-sha256 = lib.fileContents hashFile;
materialized = materializedDir;
};
combined =
let
haskellSet = pkgs.haskell-nix.stackProject materializedStackArgs;
inherit (haskellSet.haskell-ide-engine.components.exes) hie;
inherit (haskellSet.hie-bios.components.exes) hie-bios;
in (pkgs.buildEnv {
name = "haskell-ide-engine-${version.dotVersion}-${sources.hie.version}";
paths = [ hie hie-bios ];
pathsToLink = [ "/bin" ];
postBuild = "ln -s hie $out/bin/hie-wrapper";
inherit (hie) meta;
}).overrideAttrs (old: {
allowSubstitutes = true;
});
materialize =
let
haskellSet = pkgs.haskell-nix.stackProject stackArgs;
in pkgs.writeShellScript "materialize-${version.dotVersion}" ''
set -x
mkdir -p ${toString generatedDir}
nix-hash --base32 --type sha256 ${haskellSet.stack-nix} > ${toString hashFile}
${pkgs.coreutils}/bin/cp -r --no-preserve=mode -T ${haskellSet.stack-nix} ${toString materializedDir}
cp ${sources.materializationId} ${toString generatedDir}/materialization-id
'';
in unsupportedWarning {
inherit combined materialize;
}