From d0465e3837a71afae2f1a6f42eb923350d826e27 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 27 Jan 2021 10:45:51 -0500 Subject: shell.nix project.nix spine.nix mkDub.nix --- spine.nix | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'spine.nix') diff --git a/spine.nix b/spine.nix index 0dc3f67..690fb09 100755 --- a/spine.nix +++ b/spine.nix @@ -1,11 +1,14 @@ #!/usr/bin/env -S nix-build { pkgs ? import {}, stdenv ? pkgs.stdenv, - ldc ? pkgs.ldc, + ldc ? null, + dcompiler ? pkgs.ldc, dub ? pkgs.dub }: +assert dcompiler != null; #with import ./nix/mkDub.nix { inherit pkgs; }; with ( # mkDub.nix + assert dcompiler != null; with stdenv; let # Filter function to remove the .dub package folder from src @@ -19,7 +22,7 @@ with ( # mkDub.nix 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 @@ -40,7 +43,7 @@ with ( # mkDub.nix # 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; @@ -55,10 +58,10 @@ with ( # mkDub.nix ... } @ 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; @@ -71,7 +74,18 @@ with ( # mkDub.nix 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 = '' @@ -116,6 +130,7 @@ mkDubDerivation rec { sqlite nix-prefetch-git validatePkgConfig + jq ] ) ]; -- cgit v1.2.3