Use haskell.nix to keep stack and nix approaches in sync

This commit is contained in:
Luc Tielen 2019-12-11 20:59:17 +01:00
parent 70625b81d8
commit a730ec167c
No known key found for this signature in database
GPG Key ID: 30A4D06ACE9EBD3C
9 changed files with 47 additions and 69 deletions

View File

@ -1,24 +1,13 @@
{ compiler ? "ghc865", pkgs ? import nix/pkgs.nix }:
let
hlib = pkgs.haskell.lib;
hpkg = pkgs.haskell.packages."${compiler}";
llvm-hs = import ./nix/llvm-hs.nix;
in
hpkg.developPackage {
root = ./grin;
overrides = self: super: {
llvm-hs = hlib.dontCheck (self.callCabal2nix "llvm-hs" "${llvm-hs}/llvm-hs" {
llvm-config = pkgs.llvm_7;
});
llvm-hs-pure = self.callCabal2nix "llvm-hs-pure" "${llvm-hs}/llvm-hs-pure" {};
llvm-hs-pretty = self.callPackage ./nix/llvm-hs-pretty.nix {};
haskell = import ./nix/haskell.nix;
llvm-overlay = self: super: {
llvm-config = self.llvm_7;
};
modifier = drv: hlib.addBuildTools drv [
(import nix/llvm.nix {})
pkgs.clang_7
pkgs.llvm_7
];
returnShellEnv = false;
}
extra-overlays = [ llvm-overlay ];
pkgs = import ./nix/packages.nix (haskell // {
overlays = haskell.overlays ++ extra-overlays;
});
in
pkgs.haskell-nix.stackProject {
src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; };
}

7
nix/haskell-nix-src.json Normal file
View File

@ -0,0 +1,7 @@
{
"url": "https://github.com/input-output-hk/haskell.nix",
"rev": "ebdc0030e6973629c1ed7dba53c1b1d154c3e75e",
"date": "2019-12-11T01:12:46+00:00",
"sha256": "1q25sw8kz7r0wwzq780qq1cgsiy1g7iwnywckixa28psim8rp2nw",
"fetchSubmodules": false
}

8
nix/haskell.nix Normal file
View File

@ -0,0 +1,8 @@
let
spec = builtins.fromJSON (builtins.readFile ./haskell-nix-src.json);
haskell-nix-src = builtins.fetchGit {
name = "haskell-lib";
inherit (spec) url rev;
};
in
import haskell-nix-src

View File

@ -1,19 +0,0 @@
{ mkDerivation, array, base, bytestring, directory, filepath
, llvm-hs, llvm-hs-pure, mtl, prettyprinter, tasty, tasty-golden
, tasty-hspec, tasty-hunit, text, transformers, stdenv
}:
mkDerivation {
pname = "llvm-hs-pretty";
version = "0.6.1.0";
sha256 = "12w1rkkaf50jl2vdkyk4xpvjmsxzjbfkdyklaq5p6b8ykw872pda";
libraryHaskellDepends = [
array base bytestring llvm-hs-pure prettyprinter text
];
testHaskellDepends = [
base directory filepath llvm-hs llvm-hs-pure mtl tasty tasty-golden
tasty-hspec tasty-hunit text transformers
];
description = "A pretty printer for LLVM IR";
license = stdenv.lib.licenses.mit;
hydraPlatforms = stdenv.lib.platforms.none;
}

View File

@ -1,7 +0,0 @@
let
url = "https://github.com/csabahruska/llvm-hs";
ref = "llvm-7";
rev = "868e23a13942703255979369defdb49ac57b6866";
repo = builtins.fetchGit { inherit url ref rev; };
in
repo

View File

@ -1,4 +1,4 @@
{ pkgs ? import ./pkgs.nix }:
{ pkgs ? import ./packages.nix {} }:
pkgs.runCommand
"llvm-7-links"

10
nix/packages.nix Normal file
View File

@ -0,0 +1,10 @@
let
commit = "4c6e9a553872366e485766fa8b574b54b15957f8";
nixpkgs = builtins.fetchTarball {
name = "nixpkgs-19.09";
url = "https://github.com/nixos/nixpkgs/archive/${commit}.tar.gz";
sha256 = "1az9yg2lwwfw3aypi6bdsk7ghld2963vqdp8ajkxciyxdfkaxb3b";
};
pkgs = import nixpkgs;
in
pkgs

View File

@ -1,8 +0,0 @@
let
commit = "2adf2d615cf8f6c6be49a0e54dc9ebf551dcf70f";
pinned = builtins.fetchTarball {
name = "nixpkgs-19.09";
url = "https://github.com/nixos/nixpkgs/archive/${commit}.tar.gz";
sha256 = "0w8zgj38di4ssw6s0bxdb9rgksqfszsa3304863xic4bzsvkql9b";
};
in import pinned {}

View File

@ -1,14 +1,12 @@
{ pkgs ? import nix/pkgs.nix }:
let
compiler = "ghc865";
hpkg = pkgs.haskell.packages."${compiler}";
grin = import ./. { inherit compiler pkgs; };
pkgs = import ./nix/packages.nix {};
llvm-links = import ./nix/llvm.nix { inherit pkgs; };
haskellPkgs = import ./.;
in
hpkg.shellFor {
withHoogle = true;
packages = p: [ grin ];
buildInputs = with hpkg; [ cabal-install ghcid ];
inherit (grin.env) nativeBuildInputs;
}
haskellPkgs.shellFor {
buildInputs = with pkgs.haskellPackages; [
llvm-links
hlint
ghcid
];
}