at 22.05-pre 95 lines 2.8 kB view raw
1{ stdenv 2, lib 3, fetchFromGitHub 4, fetchzip 5, rustPlatform 6, bootstrap_cmds 7, DiskArbitration 8, Foundation 9, cmake 10, libiconv 11, openssl 12, perl 13, pkg-config}: 14 15let 16 fetchNpmPackage = {name, version, hash, js_prod_file, js_dev_file, ...} @ args: 17 let 18 package = fetchzip { 19 url = "https://registry.npmjs.org/${name}/-/${baseNameOf name}-${version}.tgz"; 20 inherit hash; 21 }; 22 23 static = "./src/materialized/src/http/static"; 24 cssVendor = "./src/materialized/src/http/static/css/vendor"; 25 jsProdVendor = "./src/materialized/src/http/static/js/vendor"; 26 jsDevVendor = "./src/materialized/src/http/static-dev/js/vendor"; 27 28 files = with args; [ 29 { src = js_prod_file; dst = "${jsProdVendor}/${name}.js"; } 30 { src = js_dev_file; dst = "${jsDevVendor}/${name}.js"; } 31 ] ++ lib.optional (args ? css_file) { src = css_file; dst = "${cssVendor}/${name}.css"; } 32 ++ lib.optional (args ? extra_file) { src = extra_file.src; dst = "${static}/${extra_file.dst}"; }; 33 in 34 lib.concatStringsSep "\n" (lib.forEach files ({src, dst}: '' 35 mkdir -p "${dirOf dst}" 36 cp "${package}/${src}" "${dst}" 37 '')); 38 39 npmPackages = import ./npm_deps.nix; 40in 41rustPlatform.buildRustPackage rec { 42 pname = "materialize"; 43 version = "0.9.4"; 44 rev = "29d003cae5e9d46f8b11b2102ff0b9abf6608c2f"; 45 46 src = fetchFromGitHub { 47 owner = "MaterializeInc"; 48 repo = pname; 49 rev = "v${version}"; 50 sha256 = "021n05csyvza9ifq09qaxypgmlbp3a7xn6r1m4jn8d4rnz38wag6"; 51 }; 52 53 cargoSha256 = "12fysxzmqnx7y7yg6fjcv1952s77d46pwi32vnsv62icgqfpw0j4"; 54 55 nativeBuildInputs = [ cmake perl pkg-config ] 56 # Provides the mig command used by the krb5-src build script 57 ++ lib.optional stdenv.isDarwin bootstrap_cmds; 58 59 # Needed to get openssl-sys to use pkg-config. 60 OPENSSL_NO_VENDOR = 1; 61 62 buildInputs = [ openssl ] 63 ++ lib.optionals stdenv.isDarwin [ libiconv DiskArbitration Foundation ]; 64 65 # Skip tests that use the network 66 checkFlags = [ 67 "--exact" 68 "--skip test_client" 69 "--skip test_client_errors" 70 "--skip test_no_block" 71 "--skip test_safe_mode" 72 ]; 73 74 postPatch = '' 75 ${lib.concatStringsSep "\n" (map fetchNpmPackage npmPackages)} 76 substituteInPlace ./misc/dist/materialized.service \ 77 --replace /usr/bin $out/bin \ 78 --replace _Materialize root 79 ''; 80 81 MZ_DEV_BUILD_SHA = rev; 82 cargoBuildFlags = [ "--bin materialized" ]; 83 84 postInstall = '' 85 install --mode=444 -D ./misc/dist/materialized.service $out/etc/systemd/system/materialized.service 86 ''; 87 88 meta = with lib; { 89 homepage = "https://materialize.com"; 90 description = "A streaming SQL materialized view engine for real-time applications"; 91 license = licenses.bsl11; 92 platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" ]; 93 maintainers = [ maintainers.petrosagg ]; 94 }; 95}