| Crates.io | nix-uri |
| lib.rs | nix-uri |
| version | 0.1.9 |
| created_at | 2023-12-12 12:51:19.073185+00 |
| updated_at | 2024-07-22 11:51:36.52634+00 |
| description | Parse and manipulate the nix-uri scheme to and from flakerefs. |
| homepage | https://github.com/a-kenji/nix-uri |
| repository | https://github.com/a-kenji/nix-uri |
| max_upload_size | |
| id | 1066334 |
| size | 321,197 |
nix-uri is a rust crate that parses
the nix-uri-scheme
into a FlakeRef struct.
Also allows for building a nix-uri through the 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:
{
type = "github";
owner = "NixOS";
repo = "nixpkgs";
}
To use nix-uri, add it as a dependency in your Cargo.toml file:
[dependencies]
nix-uri = "0.1.9"
or use cargo add:
cargo add nix-uri
Check out the examples directory, for more information, or run an example:
cargo run --example simple
cargo run --example cli github:nixpkgs/nixos
The uri syntax representation is parsed by this library:
github:nixos/nixpkgs: let uri = "github:nixos/nixpkgs";
let expected = FlakeRef::new(
FlakeRefType::GitHub {
owner: "nixos".into(),
repo: "nixpkgs".into(),
ref_or_rev: None,
});
let parsed: FlakeRef = uri.try_into().unwrap();
assert_eq!(expected, parsed);
It can also be generated from FlakeRef.
github:nixos/nixpkgs:let expected = "github:nixos/nixpkgs";
let uri = FlakeRef::new(
FlakeRefType::GitHub {
owner: "nixos".into(),
repo: "nixpkgs".into(),
ref_or_rev: None,
}).to_string();
assert_eq!(expected, uri);
This library is still an early WIP and not all cases are covered yet. Especially error handling is not properly implemented at this time.