nix-uri
nix-uri is a rust crate that parses
the nix-uri-scheme
into a [flakeref::FlakeRef] struct.
Also allows for building a nix-uri through the [flakeref::FlakeRef]
struct.
Convenience functionality for working with nix flake.nix references (flakerefs).
Provides types for the generic attribute set representation, but does not parse it:
{
}
Installation
To use nix-uri, add it as a dependency in your Cargo.toml file:
[dependencies]
nix-uri = "0.2.0"
or use cargo add:
cargo add nix-uri
Examples
Check out the examples directory, for more information, or run an example:
cargo run --example simple
cargo run --example cli github:nixos/nixpkgs
The uri syntax representation is parsed by this library:
Example: Parsing from github:nixos/nixpkgs:
let uri = "github:nixos/nixpkgs";
let parsed: FlakeRef = uri.parse.unwrap;
match parsed.kind
The Display round-trip preserves the original form:
Example: Round-tripping github:nixos/nixpkgs:
let uri = "github:nixos/nixpkgs";
let parsed: FlakeRef = uri.parse.unwrap;
assert_eq!;
Note
This library is still an early WIP and not all cases are covered yet. Especially error handling is not properly implemented at this time.