1{ lib
2, stdenv
3, fetchzip
4, autoPatchelfHook
5, gcc-unwrapped
6, zlib
7}:
8
9let
10 system = stdenv.hostPlatform.system;
11
12 platform = {
13 x86_64-linux = "linux-amd64";
14 aarch64-linux = "linux-aarch64";
15 x86_64-darwin = "macos-amd64";
16 aarch64-darwin = "macos-aarch64";
17 }.${system} or (throw "Unsupported system: ${system}");
18
19 packageHash = {
20 x86_64-linux = "sha256-Fp1h1X5UFOHLqgaAcXXl3oSioCMVLJLaOURHd3uu8sA=";
21 aarch64-linux = "sha256-F6/h98qZvzImuxPOMYr1cGWBjr1qWGvoYztvZzw2GRg=";
22 x86_64-darwin = "sha256-WegiHPHi9Qw4PPTEB2a9AdIgMlyOzzSpTRdJH43IEjM=";
23 aarch64-darwin = "sha256-BJER3Fp4AItqtLNYh6pH/tNB98H3iTARr3fKyTXGcP8=";
24 }.${system} or (throw "Unsupported system: ${system}");
25
26in stdenv.mkDerivation rec {
27 pname = "fermyon-spin";
28 version = "1.2.1";
29
30 src = fetchzip {
31 url = "https://github.com/fermyon/spin/releases/download/v${version}/spin-v${version}-${platform}.tar.gz";
32 stripRoot = false;
33 sha256 = packageHash;
34 };
35
36 nativeBuildInputs = [
37 autoPatchelfHook
38 ];
39
40 buildInputs = [
41 gcc-unwrapped.lib
42 zlib
43 ];
44
45 installPhase = ''
46 mkdir -p $out/bin
47 cp $src/* $out/bin
48 '';
49
50 meta = with lib; {
51 description = "Framework for building, deploying, and running fast, secure, and composable cloud microservices with WebAssembly.";
52 homepage = "https://github.com/fermyon/spin";
53 license = with licenses; [ asl20 ];
54 maintainers = with maintainers; [ mglolenstine ];
55 platforms = platforms.linux ++ platforms.darwin;
56 };
57}