Skip to content

Commit

Permalink
futhark: introduce the top-level futhark attribute
Browse files Browse the repository at this point in the history
The fact that futhark is a Haskell package is an implementation detail. To
install it users should just have to specify `futhark` instead of
`haskellPackages.futhark`.

Additionally futhark is overridden with `haskell.lib.justStaticExecutables` to
reduce closure size.
  • Loading branch information
basvandijk committed Aug 20, 2018
1 parent 376e27f commit 5ba57d5
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 78 deletions.
77 changes: 54 additions & 23 deletions pkgs/development/compilers/futhark/default.nix
Original file line number Diff line number Diff line change
@@ -1,24 +1,55 @@
{ callPackage, symlinkJoin, makeWrapper, stdenv, gcc, opencl-headers, opencl-icd }:

let
unwrapped = callPackage ./unwrapped.nix {};

path = stdenv.lib.makeBinPath [ gcc ];

wrapped = symlinkJoin {
name = "futhark-wrapped";
buildInputs = [ makeWrapper ];
paths = [ unwrapped ];
postBuild = ''
wrapProgram $out/bin/futhark-c \
--prefix PATH : "${path}"
wrapProgram $out/bin/futhark-opencl \
--prefix PATH : "${path}" \
--set NIX_CC_WRAPPER_x86_64_unknown_linux_gnu_TARGET_HOST 1 \
--set NIX_CFLAGS_COMPILE "-I${opencl-headers}/include" \
--set NIX_CFLAGS_LINK "-L${opencl-icd}/lib"
'';
# Generated using `cabal2nix --hpack .`, then replace src
{ mkDerivation, alex, array, base, bifunctors, binary, blaze-html
, bytestring, containers, data-binary-ieee754, directory
, directory-tree, dlist, extra, file-embed, filepath, gitrev, happy
, haskeline, hpack, HUnit, json, language-c-quote, mainland-pretty
, markdown, mtl, neat-interpolation, parallel, parsec, process
, process-extras, QuickCheck, random, raw-strings-qq, regex-tdfa
, srcloc, stdenv, template-haskell, temporary, test-framework
, test-framework-hunit, test-framework-quickcheck2, text
, th-lift-instances, transformers, vector, vector-binary-instances
, zlib, fetchFromGitHub
}:
mkDerivation {
pname = "futhark";
version = "0.6.2";
src = fetchFromGitHub {
owner = "diku-dk";
repo = "futhark";
rev = "v0.6.2";
sha256 = "0yj7n01swpvqblybdnks3mjf0mzf1gdg2b2cpxdpxnrjw5j0pnq2";
};

in wrapped
isLibrary = true;
isExecutable = true;
libraryHaskellDepends = [
array base bifunctors binary blaze-html bytestring containers
data-binary-ieee754 directory directory-tree dlist extra file-embed
filepath gitrev language-c-quote mainland-pretty markdown mtl
neat-interpolation parallel parsec process raw-strings-qq
regex-tdfa srcloc template-haskell text th-lift-instances
transformers vector vector-binary-instances zlib
];
libraryToolDepends = [ alex happy hpack ];
executableHaskellDepends = [
array base bifunctors binary blaze-html bytestring containers
data-binary-ieee754 directory directory-tree dlist extra file-embed
filepath gitrev haskeline json language-c-quote mainland-pretty
markdown mtl neat-interpolation parallel parsec process
process-extras random raw-strings-qq regex-tdfa srcloc
template-haskell temporary text th-lift-instances transformers
vector vector-binary-instances zlib
];
testHaskellDepends = [
array base bifunctors binary blaze-html bytestring containers
data-binary-ieee754 directory directory-tree dlist extra file-embed
filepath gitrev HUnit language-c-quote mainland-pretty markdown mtl
neat-interpolation parallel parsec process QuickCheck
raw-strings-qq regex-tdfa srcloc template-haskell test-framework
test-framework-hunit test-framework-quickcheck2 text
th-lift-instances transformers vector vector-binary-instances zlib
];
preConfigure = "hpack";
homepage = "https://futhark-lang.org";
description = "An optimising compiler for a functional, array-oriented language";
license = stdenv.lib.licenses.isc;
}
55 changes: 0 additions & 55 deletions pkgs/development/compilers/futhark/unwrapped.nix

This file was deleted.

1 change: 1 addition & 0 deletions pkgs/development/haskell-modules/configuration-common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ self: super: {
# vaultenv is not available from Hackage.
vaultenv = self.callPackage ../tools/haskell/vaultenv { };

# futhark is not available from Hackage.
futhark = self.callPackage ../compilers/futhark { };

# https://github.com/Philonous/hs-stun/pull/1
Expand Down
15 changes: 15 additions & 0 deletions pkgs/development/haskell-modules/configuration-nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -504,4 +504,19 @@ self: super: builtins.intersectAttrs super {
blank-canvas = dontCheck super.blank-canvas;
blank-canvas_0_6_2 = dontCheck super.blank-canvas_0_6_2;

futhark = with pkgs;
let path = stdenv.lib.makeBinPath [ gcc ];
in overrideCabal (addBuildTool super.futhark makeWrapper) (_drv: {
postInstall = ''
wrapProgram $out/bin/futhark-c \
--prefix PATH : "${path}"
wrapProgram $out/bin/futhark-opencl \
--prefix PATH : "${path}" \
--set NIX_CC_WRAPPER_x86_64_unknown_linux_gnu_TARGET_HOST 1 \
--set NIX_CFLAGS_COMPILE "-I${opencl-headers}/include" \
--set NIX_CFLAGS_LINK "-L${opencl-icd}/lib"
'';
});

}
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,8 @@ with pkgs;

fsmark = callPackage ../tools/misc/fsmark { };

futhark = haskell.lib.justStaticExecutables haskellPackages.futhark;

fwup = callPackage ../tools/misc/fwup { };

fzf = callPackage ../tools/misc/fzf { };
Expand Down

0 comments on commit 5ba57d5

Please sign in to comment.