|
| 1 | +{ |
| 2 | + lib, |
| 3 | + rustPlatform, |
| 4 | + fetchFromGitHub, |
| 5 | + curl, |
| 6 | + pkg-config, |
| 7 | + makeBinaryWrapper, |
| 8 | + libgit2, |
| 9 | + oniguruma, |
| 10 | + openssl, |
| 11 | + sqlite, |
| 12 | + zlib, |
| 13 | + |
| 14 | + unstableGitUpdater, |
| 15 | + writeShellScript, |
| 16 | + yq, |
| 17 | + |
| 18 | + includeLSP ? true, |
| 19 | + includeForge ? true, |
| 20 | +}: |
| 21 | +rustPlatform.buildRustPackage { |
| 22 | + pname = "steel"; |
| 23 | + version = "0.6.0-unstable-2025-02-27"; |
| 24 | + |
| 25 | + src = fetchFromGitHub { |
| 26 | + owner = "mattwparas"; |
| 27 | + repo = "steel"; |
| 28 | + rev = "f1a605a0f3fe321f4605a80c4497eda2eac5ffce"; |
| 29 | + hash = "sha256-3Iqoy2J9wY3T5jOSjtEk1aT+Q3ncNmmpQ/LY/iyvKuY="; |
| 30 | + }; |
| 31 | + |
| 32 | + useFetchCargoVendor = true; |
| 33 | + cargoHash = "sha256-PWE64CwHCQWvOGeOqdsqX6rAruWlnCwsQpcxS221M3g="; |
| 34 | + |
| 35 | + nativeBuildInputs = [ |
| 36 | + curl |
| 37 | + makeBinaryWrapper |
| 38 | + pkg-config |
| 39 | + rustPlatform.bindgenHook |
| 40 | + ]; |
| 41 | + |
| 42 | + buildInputs = [ |
| 43 | + curl |
| 44 | + libgit2 |
| 45 | + oniguruma |
| 46 | + openssl |
| 47 | + sqlite |
| 48 | + zlib |
| 49 | + ]; |
| 50 | + |
| 51 | + postPatch = '' |
| 52 | + rm .cargo/config.toml |
| 53 | + ''; |
| 54 | + |
| 55 | + cargoBuildFlags = |
| 56 | + [ |
| 57 | + "--package" |
| 58 | + "steel-interpreter" |
| 59 | + "--package" |
| 60 | + "cargo-steel-lib" |
| 61 | + ] |
| 62 | + ++ lib.optionals includeLSP [ |
| 63 | + "--package" |
| 64 | + "steel-language-server" |
| 65 | + ] |
| 66 | + ++ lib.optionals includeForge [ |
| 67 | + "--package" |
| 68 | + "forge" |
| 69 | + ]; |
| 70 | + |
| 71 | + # Tests are disabled since they always fail when building with Nix |
| 72 | + doCheck = false; |
| 73 | + |
| 74 | + postInstall = '' |
| 75 | + mkdir -p $out/lib/steel |
| 76 | +
|
| 77 | + substituteInPlace cogs/installer/download.scm \ |
| 78 | + --replace-fail '"cargo-steel-lib"' '"$out/bin/cargo-steel-lib"' |
| 79 | +
|
| 80 | + pushd cogs |
| 81 | + $out/bin/steel install.scm |
| 82 | + popd |
| 83 | +
|
| 84 | + mv $out/lib/steel/bin/repl-connect $out/bin |
| 85 | + rm -rf $out/lib/steel/bin |
| 86 | + ''; |
| 87 | + |
| 88 | + postFixup = '' |
| 89 | + wrapProgram $out/bin/steel --set-default STEEL_HOME "$out/lib/steel" |
| 90 | + ''; |
| 91 | + |
| 92 | + env = { |
| 93 | + OPENSSL_NO_VENDOR = true; |
| 94 | + RUSTONIG_SYSTEM_LIBONIG = true; |
| 95 | + STEEL_HOME = "${placeholder "out"}/lib/steel"; |
| 96 | + }; |
| 97 | + |
| 98 | + passthru.updateScript = unstableGitUpdater { |
| 99 | + tagConverter = writeShellScript "steel-tagConverter.sh" '' |
| 100 | + export PATH="${ |
| 101 | + lib.makeBinPath [ |
| 102 | + curl |
| 103 | + yq |
| 104 | + ] |
| 105 | + }:$PATH" |
| 106 | +
|
| 107 | + version=$(curl -s https://raw.githubusercontent.com/mattwparas/steel/refs/heads/master/Cargo.toml | tomlq -r .workspace.package.version) |
| 108 | +
|
| 109 | + read -r tag |
| 110 | + test "$tag" = "0" && tag="$version"; echo "$tag" |
| 111 | + ''; |
| 112 | + }; |
| 113 | + |
| 114 | + meta = { |
| 115 | + description = "Embedded scheme interpreter in Rust"; |
| 116 | + homepage = "https://github.com/mattwparas/steel"; |
| 117 | + license = with lib.licenses; [ |
| 118 | + asl20 |
| 119 | + mit |
| 120 | + ]; |
| 121 | + maintainers = with lib.maintainers; [ HeitorAugustoLN ]; |
| 122 | + mainProgram = "steel"; |
| 123 | + platforms = lib.platforms.unix; |
| 124 | + sourceProvenance = [ lib.sourceTypes.fromSource ]; |
| 125 | + }; |
| 126 | +} |
0 commit comments