-
Notifications
You must be signed in to change notification settings - Fork 6
/
flake.nix
74 lines (73 loc) · 2.61 KB
/
flake.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
70
71
72
73
74
{
description = "llvm-codegen: LLVM code generation using Haskell";
inputs = {
np.url = "github:nixos/nixpkgs?ref=master";
fu.url = "github:numtide/flake-utils?ref=master";
ds.url = "github:numtide/devshell?ref=master";
nf.url = "github:numtide/nix-filter?ref=master";
};
outputs = { self, np, fu, ds, nf, ... }@inputs:
with np.lib;
with fu.lib;
eachSystem [ "x86_64-linux" "x86_64-darwin" ] (system:
let
ghcVersion = "902";
llvmVersion = 14;
version = "${ghcVersion}.${substring 0 8 self.lastModifiedDate}.${
self.shortRev or "dirty"
}";
config = { };
overlay = final: _:
let
haskellPackages =
final.haskell.packages."ghc${ghcVersion}".override {
overrides = with final.haskell.lib;
hf: hp:
let llvm = final."llvmPackages_${toString llvmVersion}".llvm;
in {
llvm-codegen = appendConfigureFlags
((hf.callCabal2nix "llvm-codegen" (with nf.lib;
filter {
root = self;
exclude = [ ("Setup.hs") ];
}) { llvm-config = llvm; }).overrideAttrs (old: {
version = "${old.version}-${version}";
})) [
"--ghc-option=-optl=-L/${llvm}/lib"
"--ghc-option=-optl=-I/${llvm}/include"
"--ghc-option=-optl=-lLLVM-${toString llvmVersion}"
];
};
};
in { inherit haskellPackages; };
pkgs = import np {
inherit config;
system = if system == "aarch64-darwin"
then "x86_64-darwin"
else system;
overlays = [ overlay ds.overlay ];
};
in with pkgs.lib; rec {
inherit overlay;
packages = { inherit (pkgs.haskellPackages) llvm-codegen; };
defaultPackage = packages.llvm-codegen;
devShell = pkgs.devshell.mkShell {
name = "llvm-codegen";
imports = [ ];
packages = with pkgs;
with haskellPackages; [
pkgs."llvmPackages_${toString llvmVersion}".llvm.dev
pkgs.ghcid
(ghcWithPackages (p:
with p; [
hspec-discover
ghc
cabal-install
hsc2hs
hpack
haskell-language-server
]))
];
};
});
}