Skip to content

Commit

Permalink
add a nix flake for pipes-rust
Browse files Browse the repository at this point in the history
  • Loading branch information
marijncv committed Jan 2, 2025
1 parent 35f26e5 commit 2bd150a
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 1 deletion.
39 changes: 38 additions & 1 deletion libraries/pipes/implementations/rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
96 changes: 96 additions & 0 deletions libraries/pipes/implementations/rust/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions libraries/pipes/implementations/rust/flake.nix
Original file line number Diff line number Diff line change
@@ -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
'';
};
}
);
}

0 comments on commit 2bd150a

Please sign in to comment.