aboutsummaryrefslogtreecommitdiffhomepage
path: root/spine.nix
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2021-01-27 10:45:51 -0500
committerRalph Amissah <ralph.amissah@gmail.com>2021-01-27 15:33:24 -0500
commitd0465e3837a71afae2f1a6f42eb923350d826e27 (patch)
tree7e2eda3dce2ee7199044ef2cc4f53652e593e261 /spine.nix
parentmkDub.nix project.nix spine.nix (diff)
shell.nix project.nix spine.nix mkDub.nix
Diffstat (limited to 'spine.nix')
-rwxr-xr-xspine.nix27
1 files changed, 21 insertions, 6 deletions
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 <nixpkgs> {},
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
]
)
];