mirror of
https://github.com/grin-compiler/grin.git
synced 2024-08-15 17:00:34 +03:00
Repinned and refactored nix files such that nix can actually build grin.
This commit is contained in:
parent
fca2d680b7
commit
193f916bdb
18
default.nix
Normal file
18
default.nix
Normal file
@ -0,0 +1,18 @@
|
||||
{ pkgs ? import nix/pkgs.nix }:
|
||||
|
||||
let
|
||||
hlib = pkgs.haskell.lib;
|
||||
hpkg = pkgs.haskell.packages.ghc844;
|
||||
in
|
||||
|
||||
hpkg.developPackage {
|
||||
root = ./grin;
|
||||
overrides = self: super: {
|
||||
Diff = hlib.dontCheck super.Diff;
|
||||
llvm-hs = super.llvm-hs.override (oa: {
|
||||
llvm-config = pkgs.llvm_7;
|
||||
});
|
||||
};
|
||||
modifier = drv: hlib.addBuildTool drv (import nix/llvm.nix {});
|
||||
returnShellEnv = false;
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
{ Diff, mkDerivation, ansi-wl-pprint, base, bimap, bytestring, comonad
|
||||
, containers, criterion, deepseq, directory, extra, filepath, free
|
||||
, functor-infix, generic-random, ghc, ghc-paths, haskeline, hspec
|
||||
, hspec-discover, llvm-hs, llvm-hs-pretty, llvm-hs-pure
|
||||
, logict, megaparsec, microlens, microlens-mtl, microlens-platform
|
||||
, microlens-th, monad-gen, mtl, neat-interpolation
|
||||
, optparse-applicative, pretty-show, pretty-simple, process
|
||||
, QuickCheck, quickcheck-instances, recursion-schemes, set-extra
|
||||
, stdenv, template-haskell, text, text-short
|
||||
, transformers, unix, vector
|
||||
}:
|
||||
mkDerivation {
|
||||
pname = "grin";
|
||||
version = "0.1.0.0";
|
||||
src = ./.;
|
||||
isLibrary = true;
|
||||
isExecutable = true;
|
||||
libraryHaskellDepends = [
|
||||
Diff ansi-wl-pprint base bimap bytestring comonad containers deepseq
|
||||
directory extra filepath free functor-infix generic-random ghc
|
||||
hspec llvm-hs llvm-hs-pretty llvm-hs-pure logict megaparsec
|
||||
microlens microlens-mtl microlens-platform microlens-th monad-gen
|
||||
mtl neat-interpolation optparse-applicative pretty-show
|
||||
pretty-simple process QuickCheck quickcheck-instances recursion-schemes
|
||||
set-extra template-haskell text text-short transformers vector
|
||||
];
|
||||
executableHaskellDepends = [
|
||||
ansi-wl-pprint base containers directory filepath ghc ghc-paths
|
||||
haskeline llvm-hs-pretty megaparsec microlens microlens-mtl
|
||||
microlens-platform microlens-th mtl optparse-applicative
|
||||
pretty-show pretty-simple process recursion-schemes text
|
||||
transformers unix
|
||||
];
|
||||
testHaskellDepends = [
|
||||
base containers deepseq functor-infix hspec hspec-discover
|
||||
QuickCheck vector
|
||||
];
|
||||
benchmarkHaskellDepends = [ base criterion ];
|
||||
homepage = "https://github.com/githubuser/grin#readme";
|
||||
license = stdenv.lib.licenses.bsd3;
|
||||
}
|
20
nix/free.nix
20
nix/free.nix
@ -1,20 +0,0 @@
|
||||
{ mkDerivation, base, bifunctors, comonad, containers, distributive
|
||||
, exceptions, mtl, prelude-extras, profunctors, semigroupoids
|
||||
, semigroups, stdenv, template-haskell, transformers
|
||||
, transformers-compat
|
||||
}:
|
||||
mkDerivation {
|
||||
pname = "free";
|
||||
version = "4.12.4";
|
||||
sha256 = "c9fe45aae387855626ecb5a0fea6afdb207143cb00af3b1f715d1032d2d08784";
|
||||
revision = "2";
|
||||
editedCabalFile = "0gmib9bmswrqhl47cp5b871v9f44v9yidzxpljkszy49y9qdf560";
|
||||
libraryHaskellDepends = [
|
||||
base bifunctors comonad containers distributive exceptions mtl
|
||||
prelude-extras profunctors semigroupoids semigroups
|
||||
template-haskell transformers transformers-compat
|
||||
];
|
||||
homepage = "http://github.com/ekmett/free/";
|
||||
description = "Monads for free";
|
||||
license = stdenv.lib.licenses.bsd3;
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
{ mkDerivation, array, base, bytestring, directory, filepath
|
||||
, llvm-hs, llvm-hs-pure, mtl, pretty-show, stdenv, tasty
|
||||
, tasty-golden, tasty-hspec, tasty-hunit, text, transformers
|
||||
, wl-pprint-text
|
||||
}:
|
||||
mkDerivation {
|
||||
pname = "llvm-hs-pretty";
|
||||
version = "0.2.0.0";
|
||||
sha256 = "90ce478f6386f836e3b646186c4fe4d72598cc938d8fbb150718a1bbf4f4738c";
|
||||
libraryHaskellDepends = [
|
||||
array base bytestring llvm-hs-pure text wl-pprint-text
|
||||
];
|
||||
testHaskellDepends = [
|
||||
base directory filepath llvm-hs llvm-hs-pure mtl pretty-show tasty
|
||||
tasty-golden tasty-hspec tasty-hunit text transformers
|
||||
];
|
||||
homepage = "https://github.com/llvm-hs/llvm-hs-pretty";
|
||||
description = "Pretty printer for LLVM IR";
|
||||
license = stdenv.lib.licenses.mit;
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
{ mkDerivation, attoparsec, base, bytestring, containers, fail
|
||||
, hspec, mtl, stdenv, tasty, tasty-hunit, tasty-quickcheck
|
||||
, template-haskell, text, transformers, unordered-containers
|
||||
}:
|
||||
mkDerivation {
|
||||
pname = "llvm-hs-pure";
|
||||
version = "5.1.2";
|
||||
sha256 = "c4d0993aacda72107e6d34865421f128b8c27b586b95a68e2a3e94700645d954";
|
||||
libraryHaskellDepends = [
|
||||
attoparsec base bytestring containers fail mtl template-haskell
|
||||
transformers unordered-containers
|
||||
];
|
||||
testHaskellDepends = [
|
||||
base bytestring containers hspec mtl tasty tasty-hunit
|
||||
tasty-quickcheck text transformers unordered-containers
|
||||
];
|
||||
homepage = "http://github.com/llvm-hs/llvm-hs/";
|
||||
description = "Pure Haskell LLVM functionality (no FFI)";
|
||||
license = stdenv.lib.licenses.bsd3;
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
{ mkDerivation, array, attoparsec, base, bytestring, Cabal
|
||||
, containers, exceptions, llvm-config, llvm-hs-pure, mtl
|
||||
, pretty-show, QuickCheck, stdenv, tasty, tasty-hunit
|
||||
, tasty-quickcheck, template-haskell, temporary, transformers
|
||||
, utf8-string
|
||||
}:
|
||||
mkDerivation {
|
||||
pname = "llvm-hs";
|
||||
version = "5.1.3";
|
||||
sha256 = "ccdac4683f56135ba83ed0883231f686d1784e9bc7f072a34fcf041e0661976b";
|
||||
revision = "1";
|
||||
editedCabalFile = "0r8xgz6r2miw1l3az343jwz8f9jgzqywxnzl2xhanv05g3i462yh";
|
||||
setupHaskellDepends = [ base Cabal containers ];
|
||||
libraryHaskellDepends = [
|
||||
array attoparsec base bytestring containers exceptions llvm-hs-pure
|
||||
mtl template-haskell transformers utf8-string
|
||||
];
|
||||
libraryToolDepends = [ llvm-config ];
|
||||
testHaskellDepends = [
|
||||
base bytestring containers llvm-hs-pure mtl pretty-show QuickCheck
|
||||
tasty tasty-hunit tasty-quickcheck temporary transformers
|
||||
];
|
||||
homepage = "http://github.com/llvm-hs/llvm-hs/";
|
||||
description = "General purpose LLVM bindings";
|
||||
license = stdenv.lib.licenses.bsd3;
|
||||
}
|
11
nix/llvm.nix
Normal file
11
nix/llvm.nix
Normal file
@ -0,0 +1,11 @@
|
||||
{ pkgs ? import ./pkgs.nix }:
|
||||
|
||||
pkgs.runCommand
|
||||
"llvm-7-links"
|
||||
{ buildInputs = [ pkgs.llvm_7 ]; }
|
||||
''
|
||||
mkdir -p $out/bin
|
||||
cd $out/bin
|
||||
ln -s ${pkgs.llvm_7}/bin/llc llc-7
|
||||
ln -s ${pkgs.llvm_7}/bin/opt opt-7
|
||||
''
|
8
nix/pkgs.nix
Normal file
8
nix/pkgs.nix
Normal file
@ -0,0 +1,8 @@
|
||||
let
|
||||
pinned = (import <nixpkgs> {}).fetchFromGitHub {
|
||||
owner = "NixOS";
|
||||
repo = "nixpkgs-channels";
|
||||
rev = "ffc604e55790dbf575187738e1c3778231e8f5a9";
|
||||
sha256 = "1kw37ab6abkrjn65zhh0jcnfb3bzk1p14d178sp8489kn9gxy12v";
|
||||
};
|
||||
in import pinned {}
|
80
shell.nix
80
shell.nix
@ -1,74 +1,8 @@
|
||||
{ fetchFromGitHub ? (import <nixpkgs> {}).fetchFromGitHub
|
||||
# peg nix packages to specific version
|
||||
, pkgs ?
|
||||
import
|
||||
( fetchFromGitHub
|
||||
{
|
||||
owner = "NixOS";
|
||||
repo = "nixpkgs-channels";
|
||||
rev = "696c6bed4e8e2d9fd9b956dea7e5d49531e9d13f";
|
||||
sha256 = "1v3yrpj542niyxp0h3kffsdjwlrkvj0mg4ljb85d142gyn3sdzd4";
|
||||
}
|
||||
) {}
|
||||
}:
|
||||
let
|
||||
# extract the Haskell dependencies of a package
|
||||
extractHaskellDependencies = (hpkg:
|
||||
with builtins;
|
||||
let
|
||||
isHaskellPkg = x: (isAttrs x) && (x ? pname) && (x ? version) && (x ? env);
|
||||
packagesFromDrv = x:
|
||||
let
|
||||
inputs =
|
||||
(x.buildInputs or []) ++
|
||||
(x.nativeBuildInputs or []) ++
|
||||
(x.propagatedBuildInputs or []) ++
|
||||
(x.propagatedNativeBuildInputs or []);
|
||||
{ pkgs ? import nix/pkgs.nix }:
|
||||
|
||||
in
|
||||
(filter isHaskellPkg inputs);
|
||||
go1 = s: xs: foldl' go2 s xs;
|
||||
go2 = s: x:
|
||||
if s ? "${x.pname}"
|
||||
then s
|
||||
else go1 (s // {"${x.pname}" = x;}) (packagesFromDrv x);
|
||||
in assert isAttrs hpkg; attrNames (go1 {} (packagesFromDrv hpkg)));
|
||||
|
||||
# Haskell custom overrides
|
||||
haskellPackages = pkgs.haskell.packages.ghc822.override (old:
|
||||
{ overrides = self: super:
|
||||
{
|
||||
free = self.callPackage ./nix/free.nix {};
|
||||
functor-infix = pkgs.haskell.lib.doJailbreak (super.functor-infix);
|
||||
llvm-hs = self.callPackage ./nix/llvm-hs.nix {llvm-config = pkgs.llvm_5;};
|
||||
llvm-hs-pure = self.callPackage ./nix/llvm-hs-pure.nix {};
|
||||
llvm-hs-pretty = pkgs.haskell.lib.dontCheck (self.callPackage ./nix/llvm-hs-pretty.nix {});
|
||||
};
|
||||
});
|
||||
|
||||
# the grin package
|
||||
grin = pkgs.haskellPackages.callPackage ./grin {};
|
||||
# grin's dependencies
|
||||
grinDeps = extractHaskellDependencies grin;
|
||||
# use a GHC with all the Hakell dependencies and the documentation for them and a Hoogle server to search them
|
||||
ghcWith = haskellPackages.ghcWithHoogle (hs: map (x: builtins.getAttr x hs) grinDeps);
|
||||
|
||||
llc5 = pkgs.runCommand "llc5"
|
||||
{
|
||||
buildInputs = [pkgs.llvm_5];
|
||||
}
|
||||
''
|
||||
mkdir -p $out/bin
|
||||
cd $out/bin
|
||||
ln -s ${pkgs.llvm_5}/bin/llc llc-5.0
|
||||
'';
|
||||
in
|
||||
# environment setup with all the needed tools
|
||||
pkgs.runCommand "grin-shell"
|
||||
{
|
||||
shellHook = ''
|
||||
eval $(egrep ^export ${ghcWith}/bin/ghc)
|
||||
'';
|
||||
buildInputs = [ghcWith llc5 pkgs.llvm_5 haskellPackages.cabal-install];
|
||||
}
|
||||
"touch $out"
|
||||
let grin = import ./. { inherit pkgs; };
|
||||
in pkgs.haskell.packages.ghc844.shellFor {
|
||||
withHoogle = true;
|
||||
packages = p: [ grin ];
|
||||
inherit (grin.env) nativeBuildInputs;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user