From 2bd150ab605e60078d9a1dd70c42cd5d9fcbd9ec Mon Sep 17 00:00:00 2001 From: Marijn Valk Date: Thu, 2 Jan 2025 09:04:22 +0100 Subject: [PATCH] add a nix flake for pipes-rust --- .../pipes/implementations/rust/README.md | 39 +++++++- .../pipes/implementations/rust/flake.lock | 96 +++++++++++++++++++ .../pipes/implementations/rust/flake.nix | 41 ++++++++ 3 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 libraries/pipes/implementations/rust/flake.lock create mode 100644 libraries/pipes/implementations/rust/flake.nix diff --git a/libraries/pipes/implementations/rust/README.md b/libraries/pipes/implementations/rust/README.md index 7dae77c..5346adc 100644 --- a/libraries/pipes/implementations/rust/README.md +++ b/libraries/pipes/implementations/rust/README.md @@ -68,9 +68,46 @@ defs = dg.Definitions( ) ``` - ## Contributing +### Prerequisites + +- [uv](https://docs.astral.sh/uv/) +- [Rust](https://www.rust-lang.org/tools/install) + +For `nix` users, these dependencies can be installed with `nix develop`. + +### Installation + +1. Install the Python (Dagster) environment, mainly used for testing. + +```shell +uv sync +``` + +This will automatically create a virtual environment in `.venv` and install all the Python dependencies. + +To use the environment, either activate it manually with `source ./.venv/bin/activate`, or use `uv run` to execute commands in the context of this environment. + +2. To build the Rust part of the project, use: +```shell +cargo build +``` + +### Testing + +The tests can be run with cargo: + +```shell +cargo test +``` + +The integration tests are written in Python and can be run with `pytest`. The Rust project will be automatically built before running the tests. + +```shell +uv run pytest +``` + ### Pipes Schema We use [jsonschema](https://json-schema.org/) to define the pipes protocol and [quicktype](https://quicktype.io/) to generate the Rust structs. Currently, the json schemas live in `jsonschema/pipes` but they should be hosted/defined in a centralized repository in the future. diff --git a/libraries/pipes/implementations/rust/flake.lock b/libraries/pipes/implementations/rust/flake.lock new file mode 100644 index 0000000..65161bc --- /dev/null +++ b/libraries/pipes/implementations/rust/flake.lock @@ -0,0 +1,96 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1735471104, + "narHash": "sha256-0q9NGQySwDQc7RhAV2ukfnu7Gxa5/ybJ2ANT8DQrQrs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "88195a94f390381c6afcdaa933c2f6ff93959cb4", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1728538411, + "narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1735698720, + "narHash": "sha256-+skLL6mq/T7s6J5YmSp89ivQOHBPQ40GEU2n8yqp6bs=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "a00807363a8a6cae6c3fa84ff494bf9d96333674", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/libraries/pipes/implementations/rust/flake.nix b/libraries/pipes/implementations/rust/flake.nix new file mode 100644 index 0000000..9fa7ad0 --- /dev/null +++ b/libraries/pipes/implementations/rust/flake.nix @@ -0,0 +1,41 @@ +{ + description = "Dagster Pipes Rust flake"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + rust-overlay.url = "github:oxalica/rust-overlay"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { + inherit system overlays; + }; + in + with pkgs; + { + devShells.default = mkShell { + buildInputs = [ + git + openssl + uv + pkg-config + ( + rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override { + extensions = [ + "rust-src" + "rust-analyzer" + ]; + }) + ) + ]; + shellHook = '' + uv sync + ''; + }; + } + ); +}