allow packages to define nativeBuildInputs

This commit is contained in:
Christian Ulrich 2019-05-22 15:22:57 +02:00
parent 83b84fc0bd
commit 5fc2820dda
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
2 changed files with 18 additions and 10 deletions

View File

@ -1,23 +1,29 @@
{ stdenv, nim }: { stdenv, nim }:
{ name, src, nimDeps ? [], buildInputs ? [], patches ? [], patchPhase ? "", ... }: { name, src, nimDeps ? [], nativeBuildInputs ? [], buildInputs ? [],
patches ? [], patchPhase ? "", ... }:
with stdenv.lib;
let let
getRecursiveBuildInputs = deps: with stdenv.lib.lists; getRecursiveInputs = getInputsFn: deps:
optionals (deps != []) ((head deps).buildInputs ++ optionals (deps != []) ((getInputsFn (head deps)) ++
(getRecursiveBuildInputs (head deps).nimDeps) ++ (getRecursiveInputs getInputsFn (head deps).nimDeps) ++
(getRecursiveBuildInputs (tail deps))); (getRecursiveInputs getInputsFn (tail deps)));
recursiveBuildInputs = buildInputs ++ (getRecursiveBuildInputs nimDeps); rNativeBuildInputs =
nativeBuildInputs ++ (getRecursiveInputs (i: i.nativeBuildInputs) nimDeps);
rBuildInputs =
buildInputs ++ (getRecursiveInputs (i: i.buildInputs) nimDeps);
in in
stdenv.mkDerivation { stdenv.mkDerivation {
name = name; name = name;
src = src; src = src;
patches = patches; patches = patches;
nativeBuildInputs = [ nim ]; nativeBuildInputs = [ nim ] ++ (filter (i: i != nim) rNativeBuildInputs);
buildInputs = recursiveBuildInputs; buildInputs = rBuildInputs;
nimDeps = nimDeps; nimDeps = nimDeps;
patchPhase = patchPhase; patchPhase = patchPhase;
LD_LIBRARY_PATH = stdenv.lib.makeLibraryPath recursiveBuildInputs; LD_LIBRARY_PATH = makeLibraryPath (rBuildInputs ++ rNativeBuildInputs);
buildPhase = '' buildPhase = ''
HOME=$TMPDIR HOME=$TMPDIR
mkdir -p $HOME/.nimble/pkgs mkdir -p $HOME/.nimble/pkgs

View File

@ -18,7 +18,9 @@ buildNimblePackage rec {
rm ui/libui/darwin/OLD_table.m rm ui/libui/darwin/OLD_table.m
''; '';
buildInputs = [ pkg-config gtk3 ]; nativeBuildInputs = [ pkg-config ];
buildInputs = [ gtk3 ];
meta = with stdenv.lib; { meta = with stdenv.lib; {
description = "Beginnings of what might become Nim's official UI library"; description = "Beginnings of what might become Nim's official UI library";