nixpkgs/pkgs/servers/windmill/default.nix
Alyssa Ross e3e57b8f18 lib.systems: elaborate Rust metadata
We need this stuff to be available in lib so make-derivation.nix can
access it to construct the Meson cross file.

This has a couple of other advantages:

 - It makes Rust less special.  Now figuring out what Rust calls a
   platform is the same as figuring out what Linux or QEMU call it.

 - We can unify the schema used to define Rust targets, and the schema
   used to access those values later.  Just like you can set "config"
   or "system" in a platform definition, and then access those same
   keys on the elaborated platform, you can now set "rustcTarget" in
   your crossSystem, and then access "stdenv.hostPlatform.rustcTarget"
   in your code.

"rustcTarget", "rustcTargetSpec", "cargoShortTarget", and
"cargoEnvVarTarget" have the "rustc" and "cargo" prefixes because
these are not exposed to code by the compiler, and are not
standardized.  The arch/os/etc. variables are all named to match the
forms in the Rust target spec JSON.

The new rust.target-family only takes a list, since we don't need to
worry about backwards compatibility when that name is used.

The old APIs are all still functional with no warning for now, so that
it's possible for external code to use a single API on both 23.05 and
23.11.  We can introduce the warnings once 23.05 is EOL, and make them
hard errors when 23.11 is EOL.
2023-11-09 10:02:24 +01:00

165 lines
4.1 KiB
Nix

{ lib
, rustPlatform
, fetchFromGitHub
, buildNpmPackage
, bash
, cmake
, cairo
, deno
, fetchurl
, go
, lld
, makeWrapper
, nsjail
, openssl
, pango
, pixman
, pkg-config
, python3
, rustfmt
, stdenv
, swagger-cli
}:
let
pname = "windmill";
version = "1.188.1";
fullSrc = fetchFromGitHub {
owner = "windmill-labs";
repo = "windmill";
rev = "v${version}";
hash = "sha256-IiCIiP5KYRw10aPlR40RPW0ynXq5itf0LLtpDtxCNE4=";
};
pythonEnv = python3.withPackages (ps: [ ps.pip-tools ]);
frontend-build = buildNpmPackage {
inherit version;
pname = "windmill-ui";
src = fullSrc;
sourceRoot = "${fullSrc.name}/frontend";
npmDepsHash = "sha256-TgAv3iUD0kP2mOvMVOW4yYCDCsf2Cr8IfXK+V+f35uw";
# without these you get a
# FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
env.NODE_OPTIONS="--max-old-space-size=8192";
preBuild = ''
npm run generate-backend-client
'';
buildInputs = [ pixman cairo pango ];
nativeBuildInputs = [ python3 pkg-config ];
installPhase = ''
mkdir -p $out/share
mv build $out/share/windmill-frontend
'';
};
in
rustPlatform.buildRustPackage {
inherit pname version;
src = "${fullSrc}/backend";
env = {
SQLX_OFFLINE = "true";
RUSTY_V8_ARCHIVE =
let
fetch_librusty_v8 = args:
fetchurl {
name = "librusty_v8-${args.version}";
url = "https://github.com/denoland/rusty_v8/releases/download/v${args.version}/librusty_v8_release_${stdenv.hostPlatform.rust.rustcTarget}.a";
sha256 = args.shas.${stdenv.hostPlatform.system} or (throw "Unsupported platform ${stdenv.hostPlatform.system}");
meta = { inherit (args) version; };
};
in
fetch_librusty_v8 {
version = "0.74.3";
shas = {
x86_64-linux = "sha256-8pa8nqA6rbOSBVnp2Q8/IQqh/rfYQU57hMgwU9+iz4A=";
aarch64-linux = "sha256-3kXOV8rlCNbNBdXgOtd3S94qO+JIKyOByA4WGX+XVP0=";
x86_64-darwin = "sha256-iBBVKZiSoo08YEQ8J/Rt1/5b7a+2xjtuS6QL/Wod5nQ=";
aarch64-darwin = "sha256-Djnuc3l/jQKvBf1aej8LG5Ot2wPT0m5Zo1B24l1UHsM=";
};
};
};
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"progenitor-0.3.0" = "sha256-F6XRZFVIN6/HfcM8yI/PyNke45FL7jbcznIiqj22eIQ=";
"tinyvector-0.1.0" = "sha256-NYGhofU4rh+2IAM+zwe04YQdXY8Aa4gTmn2V2HtzRfI=";
};
};
patches = [
./swagger-cli.patch
./run.go.config.proto.patch
./run.python3.config.proto.patch
./run.bash.config.proto.patch
];
postPatch = ''
substituteInPlace windmill-worker/src/bash_executor.rs \
--replace '"/bin/bash"' '"${bash}/bin/bash"'
substituteInPlace windmill-api/src/lib.rs \
--replace 'unknown-version' 'v${version}'
substituteInPlace src/main.rs \
--replace 'unknown-version' 'v${version}'
'';
buildInputs = [
openssl
rustfmt
lld
];
nativeBuildInputs = [
pkg-config
makeWrapper
swagger-cli
cmake # for libz-ng-sys crate
];
preBuild = ''
pushd ..
mkdir -p frontend/build
cp -R ${frontend-build}/share/windmill-frontend/* frontend/build
cp ${fullSrc}/openflow.openapi.yaml .
popd
'';
# needs a postgres database running
doCheck = false;
postFixup = ''
patchelf --set-rpath ${lib.makeLibraryPath [openssl]} $out/bin/windmill
wrapProgram "$out/bin/windmill" \
--prefix PATH : ${lib.makeBinPath [go pythonEnv deno nsjail bash]} \
--set PYTHON_PATH "${pythonEnv}/bin/python3" \
--set GO_PATH "${go}/bin/go" \
--set DENO_PATH "${deno}/bin/deno" \
--set NSJAIL_PATH "${nsjail}/bin/nsjail"
'';
meta = {
changelog = "https://github.com/windmill-labs/windmill/blob/${fullSrc.rev}/CHANGELOG.md";
description = "Open-source developer platform to turn scripts into workflows and UIs";
homepage = "https://windmill.dev";
license = lib.licenses.agpl3Only;
maintainers = with lib.maintainers; [ dit7ya happysalada ];
mainProgram = "windmill";
# limited by librusty_v8
platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
};
}