diff options
author | Ralph Amissah <ralph.amissah@gmail.com> | 2023-06-04 18:18:21 -0400 |
---|---|---|
committer | Ralph Amissah <ralph.amissah@gmail.com> | 2023-06-04 19:21:34 -0400 |
commit | 446c0feadf7ca4a3289a5a0c9e0bbe0e74801f12 (patch) | |
tree | 50ce50da1ed20937182fe82fd7b27ff680648dae /nix-overlays/dub | |
parent | dub nix (diff) |
nix use overlays when convenient
Diffstat (limited to 'nix-overlays/dub')
-rw-r--r-- | nix-overlays/dub/default.nix | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/nix-overlays/dub/default.nix b/nix-overlays/dub/default.nix new file mode 100644 index 0000000..0ebc576 --- /dev/null +++ b/nix-overlays/dub/default.nix @@ -0,0 +1,83 @@ +{ lib, stdenv, fetchFromGitHub, curl, libevent, rsync, ldc, dcompiler ? ldc }: + +assert dcompiler != null; + +stdenv.mkDerivation rec { + pname = "dub"; + version = "1.30.0"; + + enableParallelBuilding = true; + + src = fetchFromGitHub { + owner = "dlang"; + repo = "dub"; + rev = "v${version}"; + sha256 = "sha256-iVl7bjblvIxvrUX7Phq6h4AIAmZjNVkGYYFA1hhsE7c="; + }; + + #postUnpack = '' + # patchShebangs . + #''; + + dubvar = "\\$DUB"; + postPatch = '' + patchShebangs test + + # Can be removed with https://github.com/dlang/dub/pull/1368 + substituteInPlace test/fetchzip.sh \ + --replace "dub remove" "\"${dubvar}\" remove" + ''; + + nativeBuildInputs = [ dcompiler libevent rsync ]; + buildInputs = [ curl ]; + + buildPhase = '' + for DC_ in dmd ldmd2 gdmd; do + echo "... check for D compiler $DC_ ..." + export DC=$(type -P $DC_ || echo "") + if [ ! "$DC" == "" ]; then + break + fi + done + if [ "$DC" == "" ]; then + exit "Error: could not find D compiler" + fi + echo "$DC_ found and used as D compiler in buildPhase for $pname" + $DC ./build.d + ./build + ''; + + doCheck = !stdenv.isDarwin; + + checkPhase = '' + export DUB=$NIX_BUILD_TOP/source/bin/dub + export PATH=$PATH:$NIX_BUILD_TOP/source/bin/ + #export DC=${dcompiler.out}/bin/${if dcompiler.pname=="ldc" then "ldc2" else dcompiler.pname} + if [ "$DC" == "" ]; then + exit "Error: could not find D compiler" + fi + echo "DC out --> $DC" + export HOME=$TMP + + rm -rf test/issue502-root-import + rm -rf test/dpath-variable + rm test/dpath-variable.sh + rm -rf test/git-dependency + rm -rf test/use-c-sources # added to build v1.33.0 + + ./test/run-unittest.sh + ''; + + installPhase = '' + mkdir -p $out/bin + cp bin/dub $out/bin + ''; + + meta = with lib; { + description = "Package and build manager for D applications and libraries"; + homepage = "https://code.dlang.org/"; + license = licenses.mit; + maintainers = with maintainers; [ ThomasMader ]; + platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + }; +} |