Rulid is a new and experimental build system for Rust
While Rulid currently has a single implementation, nothing is stopping you from making another one and interoperating with us. After all, nothing is better than standards.
SpecRulid has first-class support for decentralized packages. Compared to traditional package managers that fetch their packages from a central repository; Rulid lets you download and distribute packages from any repository.
Rulid has experimental support for package distribution over IPFS. This means once you pin a package, you can securely fetch it in a P2P fashion.
Centralized package managers have problems with deleted packages. Once you pin an IPFS package with Rulid, it should be available from any peer that has it in the cache.
The web is inherently decentralized. Rulid lets you take full advantage of that by being able to fetch packages from any URL.
Rulid support dependencies from local directories, and local package files. Use cases for this include development, monorepos and network shares with internal packages.
Here's an example to get you going with Rulid. We'll build a program that generates numbers using a PRNG. Create an empty directory and put two files in it.
pkgmeta
name ExampleApp
author Mr Doctor
type bin
dep lcg index lcg_rand
main.rs
use lcg::LCG;
fn main() {
let mut rng = LCG::new();
for _ in 0..10 {
println!("Your number is: {}", rng.next());
}
}
If you have installed Rulid correctly, you should be able to
build this program by typing rulid build.
You can install dependencies to your package by adding a line to your pkgmeta file. Dependency lines are made up of three main parts; name, method and locator. Let's head back to the previous section and and take a closer look at the dependency there.
dep lcg index lcg_rand
This can be read roughly as; using the index, find the package called lcg_rand and add it to my project as lcg. Even though the actual package name is lcg_rand, we can use it in our Rust code under a different name. While this sounds like it can get really messy, it is actually a really powerful construct that lets you swap libraries that implement the same interface.
Let's take a closer look at the various methods we can use to resolve our dependencies.
This one is used mostly for local development. It references an un-packaged local path as a dependency.
dep random path ../test-random-generator
This line will build the library on the directory you specify, and import it to your project under the name random.
This method references a packaged dependency on the local filesystem. It needs the dependency to be packaged in a tar.gz file, but it is otherwise similar to the Path method.
dep random local /home/leo/deps/enterprise-random.tar.gz
This line imports the package enterprise-random.tar.gz as random.
The URL method downloads a package from a given URL, unpacks it to a temporary folder, and imports it to your project after building it.
dep random url https://gkbrk.com/packages/super-random.tar.gz
The future is here. The IPFS method can fetch packages over the P2P IPFS network, and transparently import them to your project. While this method is currently experimental, it is not expected to be too unstable.
dep random ipfs Qmaz5Foih95PyW3DRobzqEtReNd2CiVEtXDK12BMjy6PNH
Remember the example project you built on Getting Started? That dependency actually came from IPFS.
This method finds a package name in the Package Index. The index is basically a text file that point to other methods. A package can be referred to by a common name in the index, but the package can be updated, moved or load balanced.
dep random index lcg_rand
Decentralization is good, but this isn't the wild west. If you still want a semblance of order; check out our package index.
It features a curated selection of high quality packages, or examples if you want to make your own packages.
Package IndexYou can install a prepackaged version from PyPI using pip.
pip install Rulid
or alternatively
The following snippet will download the Rulid source code and install it to your binaries folder. This will allow you to run Rulid anywhere on your system to build projects.
wget https://www.rulidpkg.com/rulid
chmod +x rulid
sudo mv rulid /usr/bin/
Rulid packages are distributed as tar.gz files.
// TODO: Write spec
© 2020 Gokberk Yaltirakli