Crate nix_uri

Crate nix_uri 

Source
Expand description

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";
   }

§Installation

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

§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 expected = FlakeRef::new(
               FlakeRefType::GitForge (GitForge{
               platform: GitForgePlatform::GitHub,
               owner: "nixos".into(),
               repo: "nixpkgs".into(),
               ref_or_rev: None,
               }));
    let parsed: FlakeRef = uri.parse().unwrap();
    assert_eq!(expected, parsed);

It can also be generated from FlakeRef.

§Example: Constructing the following uri github:nixos/nixpkgs:

let expected = "github:nixos/nixpkgs";
let uri = FlakeRef::new(
              FlakeRefType::GitForge (GitForge{
              platform: GitForgePlatform::GitHub,
              owner: "nixos".into(),
              repo: "nixpkgs".into(),
              ref_or_rev: None,
              })).to_string();
   assert_eq!(expected, uri);

Modules§

urls

Structs§

FlakeRef
The General Flake Ref Schema
GitForge
LocationParameters

Enums§

BaseErrorKind
The kind of base error
ErrorTree
Custom error tree type compatible with nom 8.0 This provides similar functionality to nom-supreme’s ErrorTree
Expectation
What was expected when parsing
FlakeRefType
GitForgePlatform
LocationParamKeys
NixUriError
RefLocation
Indicates where a ref or rev is stored in a FlakeRef
StackContext
Context added to a stack
TransportLayer
Specifies the +<layer> component, e.g. git+https://

Functions§

tag
A tag combinator that produces nice error messages with Expected(Tag(...)) This is similar to nom-supreme’s tag functionality

Type Aliases§

IErr
NixUriResult