|
| 1 | +{ |
| 2 | + fetchFromGitHub, |
| 3 | + lib, |
| 4 | + makeWrapper, |
| 5 | + ruby, |
| 6 | + stdenv, |
| 7 | + versionCheckHook, |
| 8 | +}: |
| 9 | + |
| 10 | +stdenv.mkDerivation (finalAttrs: { |
| 11 | + pname = "haiti"; |
| 12 | + version = "3.0.0"; |
| 13 | + |
| 14 | + src = fetchFromGitHub { |
| 15 | + owner = "noraj"; |
| 16 | + repo = "haiti"; |
| 17 | + tag = "v${finalAttrs.version}"; |
| 18 | + hash = "sha256-1PGGlnbw8zg2sNEc85Un7no7elS5aPSfjzfmqovmiHk="; |
| 19 | + }; |
| 20 | + |
| 21 | + nativeBuildInputs = [ |
| 22 | + makeWrapper |
| 23 | + ruby |
| 24 | + ]; |
| 25 | + |
| 26 | + paintSrc = fetchFromGitHub { |
| 27 | + owner = "janlelis"; |
| 28 | + repo = "paint"; |
| 29 | + rev = "7076784c5d57f178690d19e4f8644441ff73f518"; |
| 30 | + hash = "sha256-uITUfcZjOACeCGsozpUxAYd98Y9oFTgyXems2Q3aYRU="; |
| 31 | + }; |
| 32 | + |
| 33 | + docoptSrc = fetchFromGitHub { |
| 34 | + owner = "docopt"; |
| 35 | + repo = "docopt.rb"; |
| 36 | + rev = "794c47d7cb62ca71d65086623a55881449bc2f9e"; |
| 37 | + hash = "sha256-9DbKTPsZRRAqDkN2wMzBtbbtyKDcVSGmVDcekf4WBnw="; |
| 38 | + }; |
| 39 | + |
| 40 | + buildPhase = '' |
| 41 | + runHook preBuild |
| 42 | +
|
| 43 | + paintBuild=$(mktemp -d) |
| 44 | + cp -r ${finalAttrs.paintSrc}/* $paintBuild |
| 45 | + pushd $paintBuild |
| 46 | + sed -i '/.github/d' paint.gemspec |
| 47 | + sed -i '/.rspec/d' paint.gemspec |
| 48 | + gem build -V paint.gemspec |
| 49 | + popd |
| 50 | + paintGem=$paintBuild/paint-2.3.0.gem |
| 51 | +
|
| 52 | + docoptBuild=$(mktemp -d) |
| 53 | + cp -r ${finalAttrs.docoptSrc}/* $docoptBuild |
| 54 | + pushd $docoptBuild |
| 55 | + gem build -V docopt.gemspec |
| 56 | + popd |
| 57 | + docoptGem=$docoptBuild/docopt-0.6.1.gem |
| 58 | +
|
| 59 | + gem build -V haiti.gemspec |
| 60 | +
|
| 61 | + runHook postBuild |
| 62 | + ''; |
| 63 | + |
| 64 | + installPhase = '' |
| 65 | + runHook preInstall |
| 66 | +
|
| 67 | + gem install -V $paintGem $docoptGem haiti-hash-${finalAttrs.version}.gem \ |
| 68 | + --install-dir=$out/lib \ |
| 69 | + --ignore-dependencies |
| 70 | +
|
| 71 | + for i in $out/lib/bin/*; |
| 72 | + do |
| 73 | + filename=$(basename $i) |
| 74 | + makeWrapper ${lib.getExe ruby} $out/bin/$filename \ |
| 75 | + --set GEM_PATH $out/lib \ |
| 76 | + --add-flags $out/lib/bin/$filename |
| 77 | + done |
| 78 | +
|
| 79 | + rm -rf $out/lib/{build_info,cache,doc,extensions,plugins} |
| 80 | +
|
| 81 | + runHook postInstall |
| 82 | + ''; |
| 83 | + |
| 84 | + doInstallCheck = true; |
| 85 | + nativeInstallCheckInputs = [ versionCheckHook ]; |
| 86 | + |
| 87 | + meta = { |
| 88 | + changelog = "https://github.com/noraj/haiti/releases/tag/v${finalAttrs.version}"; |
| 89 | + description = "CLI tool to identify hash types"; |
| 90 | + homepage = "https://github.com/noraj/haiti"; |
| 91 | + license = lib.licenses.mit; |
| 92 | + mainProgram = "haiti"; |
| 93 | + maintainers = with lib.maintainers; [ KSJ2000 ]; |
| 94 | + platforms = lib.platforms.unix; |
| 95 | + }; |
| 96 | +}) |
0 commit comments