Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ivan770/freight
Nix Flake for building Rust-based Cloudflare Workers
https://github.com/ivan770/freight
cloudflare cloudflare-workers flake nix nixos rust serverless
Last synced: 8 days ago
JSON representation
Nix Flake for building Rust-based Cloudflare Workers
- Host: GitHub
- URL: https://github.com/ivan770/freight
- Owner: ivan770
- License: apache-2.0
- Created: 2023-10-22T21:31:19.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-04-04T10:22:54.000Z (10 months ago)
- Last Synced: 2025-01-29T01:51:28.595Z (13 days ago)
- Topics: cloudflare, cloudflare-workers, flake, nix, nixos, rust, serverless
- Language: Nix
- Homepage:
- Size: 13.7 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Freight
Build your Rust-based Cloudflare Workers® with Nix!
* Automatically installs `wasm-pack` and `wasm-bindgen` by analyzing project dependencies.
* Maintains compatibility with the `worker-build` build process.
* Supports custom Rust toolchains.## Getting started
You can use the following command to create a new Nix project with pre-configured Nix Flake:
```sh
nix flake init -t github:ivan770/freight
cargo update
wrangler deploy
```Make sure that your Nix installation [supports Flakes](https://nixos.wiki/wiki/Flakes#Enable_flakes).
## Usage
Freight provides a single function named `mkWorker`, that allows you to build your projects.
`mkWorker :: set -> drv`
This function encapsulates both building (with `wasm-pack` and `wasm-bindgen`) and bundling (with `esbuild`) steps
of a project build lifecycle.Required attributes are `pname`, `version` and `src`.
You may specify any attributes supported by the
[`mkCargoDerivation`](https://crane.dev/API.html#cranelibmkcargoderivation)
from the [crane](https://github.com/ipetkov/crane) project.You may optionally replace the default Rust toolchain with your own using the `craneLib` attribute.
See [crane documentation](https://crane.dev/examples/custom-toolchain.html) for more information on how to use custom toolchains.## License
This project is licensed under Apache License, Version 2.0.
Cloudflare, the Cloudflare logo, and Cloudflare Workers are trademarks and/or registered trademarks of Cloudflare, Inc. in the United States and other jurisdictions.