dream2nix
dream2nix copied to clipboard
Add minimal local Rust example
I'm trying to package a small Rust project within NixOS and really like that just works (build and package) with minimal Nix code.
Having tried dream2nix (Rust within NixOS in general) for the first time i believe a minimal, local Rust example would have helped me a lot. I would like to add PR with such an example project with some explanation. Would a small hello-world example like the following be ok?
# flake.nix
{
description = "Minimal Rust dream2nix example";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
dream2nix.url = "github:nix-community/dream2nix";
dream2nix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, lib, dream2nix }:
dream2nix.lib.makeFlakeOutputs {
systems = ["x86_64-linux"];
config.projectRoot = ./.;
source = lib.sourceFilesBySuffices ./. [
".rs"
"Cargo.toml"
"Cargo.lock"
];
projects."rust-dream2nix" = {
name = "rust-dream2nix";
translator = "cargo-lock";
};
# With Rust workspaces better run auto-detection
# "nix run github:nix-community/dream2nix#detect-projects ."
# to generate a `projects.toml` file to reference here:
# projects = ./projects.toml;
};
}
# projects.toml
[rust-dream2nix]
name = "rust-dream2nix"
translator = "cargo-lock"
# optional settings
# subsystem = "rust"
# relPath = ""
# translators = [ "cargo-lock", "cargo-toml",]
# builder = "crane"
- If ok, should this be an example with its own folder in https://github.com/nix-community/dream2nix/tree/main/examples, or be listed in the docs https://nix-community.github.io/dream2nix/subsystems/rust.html?
- What is the name in
projects.tomlfor? At least with a single Rust project (no workspace) i have to set it, but it seems the value can be anything. - Also i've seen some example using fennix. When would that be useful, since crane (the current default builder) seems to be working fine.
- What is an IFD and why is that an issue? An explanation or better a link in the Rust section to a beginner-friendly explanation would be good (i could add that).