Nix packages for third-party projects that don't ship their own flakes
2.4 kB
67 lines
1{
2 lib,
3 stdenv,
4 fetchurl,
5 versionCheckHook,
6}:
7
8let
9 # Prebuilt static (Linux musl) / native (macOS) binaries from GitHub releases.
10 # Asset names: gleam-v{version}-{target}.tar.gz — each archive is a single `gleam`.
11 sources = {
12 x86_64-linux = {
13 url = "https://github.com/gleam-lang/gleam/releases/download/v1.18.0-rc1/gleam-v1.18.0-rc1-x86_64-unknown-linux-musl.tar.gz";
14 hash = "sha256-4nCA6pli6Z7O2Uy8A+ffHgnEd2ATBQo/zA+nWFyKqlo=";
15 };
16 aarch64-linux = {
17 url = "https://github.com/gleam-lang/gleam/releases/download/v1.18.0-rc1/gleam-v1.18.0-rc1-aarch64-unknown-linux-musl.tar.gz";
18 hash = "sha256-d3z6GuSUIDEYWweSNZba0Pgxd/88LJ1riwkDbxsrAms=";
19 };
20 x86_64-darwin = {
21 url = "https://github.com/gleam-lang/gleam/releases/download/v1.18.0-rc1/gleam-v1.18.0-rc1-x86_64-apple-darwin.tar.gz";
22 hash = "sha256-f1iBXb6djyTGDQ4I2o73j87zqBxFnFuECe9JhjiwAkU=";
23 };
24 aarch64-darwin = {
25 url = "https://github.com/gleam-lang/gleam/releases/download/v1.18.0-rc1/gleam-v1.18.0-rc1-aarch64-apple-darwin.tar.gz";
26 hash = "sha256-UYDqJiHrcLnoqPFOavJBa9/RF1dBrxmOPBt6K8g5QCA=";
27 };
28 };
29
30 srcAttrs =
31 sources.${stdenv.hostPlatform.system}
32 or (throw "gleam-preview: unsupported system ${stdenv.hostPlatform.system}");
33in
34stdenv.mkDerivation (finalAttrs: {
35 pname = "gleam-preview";
36 # Official prerelease tags are vX.Y.Z-rcN (and similar) on GitHub.
37 version = "1.18.0-rc1";
38
39 src = fetchurl {
40 inherit (srcAttrs) url hash;
41 };
42
43 # Archive root is just the `gleam` binary (no directory wrapper).
44 sourceRoot = ".";
45
46 installPhase = ''
47 runHook preInstall
48 # Install as gleam-preview so this can coexist with nixpkgs gleam on PATH.
49 install -Dm755 gleam $out/bin/gleam-preview
50 runHook postInstall
51 '';
52
53 nativeInstallCheckInputs = [ versionCheckHook ];
54 versionCheckProgram = "${placeholder "out"}/bin/gleam-preview";
55 versionCheckProgramArg = "--version";
56 doInstallCheck = true;
57
58 meta = {
59 description = "Statically typed language for the Erlang VM (official prerelease binaries)";
60 homepage = "https://gleam.run";
61 changelog = "https://github.com/gleam-lang/gleam/releases/tag/v${finalAttrs.version}";
62 license = lib.licenses.asl20;
63 mainProgram = "gleam-preview";
64 platforms = builtins.attrNames sources;
65 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
66 };
67})