nix-uri

Crates Documentation

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:

no_run { type = "github"; owner = "NixOS"; repo = "nixpkgs"; }

The uri syntax representation is parsed by this library:

Example github:a-kenji/nala:

rust let uri = "github:nixos/nixpkgs"; let expected = FlakeRef::default() .r#type(FlakeRefType::GitHub { owner: "nixos".into(), repo: "nixpkgs".into(), ref_or_rev: None, }) .clone(); let parsed: FlakeRef = uri.try_into().unwrap(); assert_eq!(expected, parsed);

It can also be generated from FlakeRef. ## Example: github:nixos/nixpkgs: rust let expected = "github:nixos/nixpkgs"; let uri = FlakeRef::default() .r#type(FlakeRefType::GitHub { owner: "nixos".into(), repo: "nixpkgs".into(), ref_or_rev: None, }).to_string(); assert_eq!(expected, uri);

Note

This library is still a WIP and not all cases are covered yet.