Skip to content

Commit

Permalink
nix: rust support (#4957)
Browse files Browse the repository at this point in the history
  • Loading branch information
uael authored Dec 20, 2024
1 parent d45cdf8 commit 71d527c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
9 changes: 5 additions & 4 deletions backend/windmill-worker/src/rust_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ use windmill_queue::{append_logs, CanceledBy};

use crate::{
common::{
check_executor_binary_exists, create_args_and_out_file, get_reserved_variables, read_result, start_child_process, OccupancyMetrics
check_executor_binary_exists, create_args_and_out_file, get_reserved_variables,
read_result, start_child_process, OccupancyMetrics,
},
handle_child::handle_child,
AuthedClientBackgroundTask, DISABLE_NSJAIL, DISABLE_NUSER, HOME_ENV, NSJAIL_PATH, PATH_ENV,
Expand All @@ -31,7 +32,7 @@ lazy_static::lazy_static! {
static ref HOME_DIR: String = std::env::var("HOME").expect("Could not find the HOME environment variable");
static ref CARGO_HOME: String = std::env::var("CARGO_HOME").unwrap_or_else(|_| { CARGO_HOME_DEFAULT.clone() });
static ref RUSTUP_HOME: String = std::env::var("RUSTUP_HOME").unwrap_or_else(|_| { RUSTUP_HOME_DEFAULT.clone() });
static ref CARGO_PATH: String = format!("{}/bin/cargo", CARGO_HOME.as_str());
static ref CARGO_PATH: String = std::env::var("CARGO_PATH").unwrap_or_else(|_| format!("{}/bin/cargo", CARGO_HOME.as_str()));
}

#[cfg(windows)]
Expand All @@ -42,8 +43,8 @@ lazy_static::lazy_static! {

#[cfg(unix)]
lazy_static::lazy_static! {
static ref CARGO_HOME_DEFAULT: String = "/usr/local/cargo".to_string();
static ref RUSTUP_HOME_DEFAULT: String = "/usr/local/rustup".to_string();
static ref CARGO_HOME_DEFAULT: String = format!("{}/.cargo", *HOME_DIR);
static ref RUSTUP_HOME_DEFAULT: String = format!("{}/.rustup", *HOME_DIR);
}

const RUST_OBJECT_STORE_PREFIX: &str = "rustbin/";
Expand Down
32 changes: 17 additions & 15 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@
inherit system;
overlays = [ (import rust-overlay) ];
};
rust = pkgs.rust-bin.stable.latest.default.override {
extensions = [
"rust-src" # for rust-analyzer
"rust-analyzer"
];
};
buildInputs = with pkgs; [
openssl openssl.dev libxml2.dev xmlsec.dev libxslt.dev
rust-bin.stable.latest.default nodejs cmake
rust nodejs
postgresql
pkg-config
pkg-config cmake
];
PKG_CONFIG_PATH = pkgs.lib.makeSearchPath "lib/pkgconfig" (with pkgs; [
openssl.dev
Expand All @@ -27,7 +33,7 @@
in {
devShell = pkgs.mkShell {
buildInputs = buildInputs ++ (with pkgs; [
git xcaddy sqlx-cli flock rust-analyzer
git xcaddy sqlx-cli flock sccache
deno python3 python3Packages.pip go bun uv
]);
packages = [
Expand Down Expand Up @@ -74,12 +80,14 @@
DATABASE_URL = "postgres://postgres:changeme@127.0.0.1:5432/";
REMOTE = "http://127.0.0.1:8000";
REMOTE_LSP = "http://127.0.0.1:3001";
RUSTC_WRAPPER = "${pkgs.sccache}/bin/sccache";
DENO_PATH = "${pkgs.deno}/bin/deno";
PYTHON_PATH = "${pkgs.python3}/bin/python3";
GO_PATH = "${pkgs.go}/bin/go";
BUN_PATH = "${pkgs.bun}/bin/bun";
UV_PATH = "${pkgs.uv}/bin/uv";
FLOCK_PATH = "${pkgs.flock}/bin/flock";
CARGO_PATH = "${rust}/bin/cargo";
};
packages.default = self.packages.${system}.windmill;
packages.windmill-client = pkgs.stdenv.mkDerivation {
Expand Down Expand Up @@ -107,32 +115,26 @@
pname = "windmill";
version = (pkgs.lib.strings.trim (builtins.readFile ./version.txt));

src = ./.;
nativeBuildInputs = buildInputs ++ [ self.packages.${system}.windmill-client ];
src = ./backend;
nativeBuildInputs = buildInputs;

cargoRoot = "backend";
cargoLock = {
lockFile = ./backend/Cargo.lock;
outputHashes = {
"php-parser-rs-0.1.3" = "sha256-ZeI3KgUPmtjlRfq6eAYveqt8Ay35gwj6B9iOQRjQa9A=";
"progenitor-0.3.0" = "sha256-F6XRZFVIN6/HfcM8yI/PyNke45FL7jbcznIiqj22eIQ=";
"rustpython-ast-0.3.1" = "sha256-q9N+z3F6YICQuUMp3a10OS792tCq0GiSSlkcaLxi3Gs=";
"tiberius-0.12.2" = "sha256-s/S0K3hE+JNCrNVxoSCSs4myLHvukBYTwk2A5vZ7Ae8=";
"tinyvector-0.1.0" = "sha256-NYGhofU4rh+2IAM+zwe04YQdXY8Aa4gTmn2V2HtzRfI=";
};
};

buildFeatures = [ ];
buildFeatures = [
"embedding" "parquet" "openidconnect" "jemalloc" "deno_core" "license" "http_trigger" "zip" "oauth2" "dind"
"php" "mysql" "mssql" "bigquery" "websocket" "python" "smtp" "csharp" "rust"
];
doCheck = false;
preBuild = ''
export HOME=$(pwd)
npm config set strict-ssl false
cd backend
'';

inherit PKG_CONFIG_PATH;
SQLX_OFFLINE = true;
FRONTEND_BUILD_DIR = "${self.packages.${system}.windmill-client}/build";
RUSTY_V8_ARCHIVE =
let
version = "130.0.1";
Expand Down

0 comments on commit 71d527c

Please sign in to comment.