diff --git a/pkgs/by-name/df/dformat/dub-lock.json b/pkgs/by-name/df/dformat/dub-lock.json new file mode 100644 index 000000000000..4776c1dbac2e --- /dev/null +++ b/pkgs/by-name/df/dformat/dub-lock.json @@ -0,0 +1,8 @@ +{ + "dependencies": { + "libdparse": { + "version": "0.25.0", + "sha256": "012ihzwhikvpd7crr3ql38hs32lfy9gnkg9qvjgpd7ar3xbsa5sz" + } + } +} diff --git a/pkgs/by-name/df/dformat/fix_version.patch b/pkgs/by-name/df/dformat/fix_version.patch new file mode 100644 index 000000000000..5ffd727cc33c --- /dev/null +++ b/pkgs/by-name/df/dformat/fix_version.patch @@ -0,0 +1,13 @@ +diff --git a/dub.json b/dub.json +index a0d6357..abae578 100644 +--- a/dub.json ++++ b/dub.json +@@ -13,8 +13,5 @@ + ], + "versions" : [ + "built_with_dub" +- ], +- "preBuildCommands" : [ +- "$DC -run \"$PACKAGE_DIR/dubhash.d\"" + ] + } diff --git a/pkgs/by-name/df/dformat/package.nix b/pkgs/by-name/df/dformat/package.nix new file mode 100644 index 000000000000..54bce54029d4 --- /dev/null +++ b/pkgs/by-name/df/dformat/package.nix @@ -0,0 +1,53 @@ +{ + lib, + buildDubPackage, + fetchFromGitHub, + versionCheckHook, +}: + +buildDubPackage rec { + pname = "dfmt"; + version = "0.15.2"; + + src = fetchFromGitHub { + owner = "dlang-community"; + repo = "dfmt"; + tag = "v${version}"; + hash = "sha256-QjmYPIQFs+91jB1sdaFoenfWt5TLXyEJauSSHP2fd+M="; + }; + + preBuild = '' + mkdir -p bin/ + echo "v${version}" > bin/dubhash.txt + ''; + + patches = [ + # do not run the dubhash tool, we supply the version in preBuild + ./fix_version.patch + ]; + + dubLock = ./dub-lock.json; + + doCheck = true; + + installPhase = '' + runHook preInstall + install -Dm755 bin/dfmt -t $out/bin + runHook postInstall + ''; + + nativeInstallCheckInputs = [ + versionCheckHook + ]; + + doInstallCheck = true; + + meta = { + description = "Formatter for D source code"; + changelog = "https://github.com/dlang-community/dfmt/releases/tag/v${version}"; + homepage = "https://github.com/dlang-community/dfmt"; + maintainers = with lib.maintainers; [ ipsavitsky ]; + mainProgram = "dfmt"; + license = lib.licenses.boost; + }; +}