aboutsummaryrefslogtreecommitdiffhomepage
path: root/nix/mkDub.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nix/mkDub.nix')
-rw-r--r--nix/mkDub.nix25
1 files changed, 19 insertions, 6 deletions
diff --git a/nix/mkDub.nix b/nix/mkDub.nix
index 8f4014b..2a6570f 100644
--- a/nix/mkDub.nix
+++ b/nix/mkDub.nix
@@ -1,8 +1,10 @@
{ pkgs ? import <nixpkgs> {},
stdenv ? pkgs.stdenv,
- ldc ? pkgs.ldc,
+ ldc ? null,
+ dcompiler ? pkgs.ldc,
dub ? pkgs.dub
}:
+assert dcompiler != null;
with stdenv;
let
# Filter function to remove the .dub package folder from src
@@ -16,7 +18,7 @@ let
fromDub = dubDep: mkDerivation rec {
name = "${src.name}-${version}";
version = rev-to-version dubDep.fetch.rev;
- nativeBuildInputs = [ ldc dub ];
+ nativeBuildInputs = [ dcompiler dub ];
src = dep2src dubDep;
buildPhase = ''
runHook preBuild
@@ -37,7 +39,7 @@ let
# The target output of the Dub package
targetOf = package: "${package.targetPath or "."}/${package.targetName or package.name}";
# Remove reference to build tools and library sources
- disallowedReferences = deps: [ ldc dub ] ++ builtins.map dep2src deps;
+ disallowedReferences = deps: [ dcompiler dub ] ++ builtins.map dep2src deps;
removeExpr = refs: ''remove-references-to ${lib.concatMapStrings (ref: " -t ${ref}") refs}'';
in {
inherit fromDub;
@@ -52,10 +54,10 @@ in {
...
} @ attrs: stdenv.mkDerivation (attrs // {
pname = package.name;
- nativeBuildInputs = [ ldc dub pkgs.removeReferencesTo ] ++ nativeBuildInputs;
+ nativeBuildInputs = [ dcompiler dub pkgs.removeReferencesTo ] ++ nativeBuildInputs;
disallowedReferences = disallowedReferences deps;
passthru = passthru // {
- inherit dub ldc pkgs;
+ inherit dub dcompiler pkgs;
};
src = lib.cleanSourceWith {
filter = filterDub;
@@ -68,7 +70,18 @@ in {
runHook preBuild
export HOME=$PWD
${lib.concatMapStringsSep "\n" dub-add-local deps}
- dub build --compiler=ldc2 --build=release --combined --skip-registry=all
+ for dc_ in dmd ldmd2 gdmd; do
+ echo "check for D compiler $dc_"
+ dc=$(type -P $dc_ || echo "")
+ if [ ! "$dc" == "" ]; then
+ break
+ fi
+ done
+ if [ "$dc" == "" ]; then
+ exit "Error: could not find D compiler"
+ fi
+ echo "$dc_ used as D compiler to build $pname"
+ dub build --compiler=$dc --build=release --combined --skip-registry=all
runHook postBuild
'';
checkPhase = ''