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

View File

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