nix_data/lib.rs
1//! A set of modules for easily managing Nix and NixOS packages and options.
2//! 
3//! This crate contains a [cache](crate::cache) module for caching Nix/NixOS packages and options,
4//! such as the latest `packages.json` and `options.json` from the NixOS cache.
5//! 
6//! This crate also contains a [config](crate::config) module for maintaining a set of important Nix/NixOS details,
7//! such as the location of the users `configuration.nix` file, and whether they are using flakes or not.
8//! This can be useful so that not ever application/utility needs to maintain their own config files and preferences.
9//! 
10//! # Example
11//! ```
12//! extern crate nix_data;
13//!  
14//! fn main() {
15//!     let userpkgs = nix_data::cache::profile::getprofilepkgs_versioned();
16//!     if let Ok(pkgs) = userpkgs {
17//!         println!("List of installed nix profile packages");
18//!         println!("===");
19//!         for (pkg, version) in pkgs {
20//!             println!("{}: {}", pkg, version);
21//!         }
22//!     }
23//! }
24//! ```
25
26/// A module for downloading and caching lists of Nix/NixOS packages and options.
27pub mod cache;
28/// A module for managing the configuration containing user and system options.
29pub mod config;
30
31pub mod utils;
32
33lazy_static::lazy_static! {
34    static ref CACHEDIR: String = format!("{}/.cache/nix-data", std::env::var("HOME").unwrap());
35    static ref CONFIGDIR: String = format!("{}/.config/nix-data", std::env::var("HOME").unwrap());
36    static ref CONFIG: String = format!("{}/config.json", &*CONFIGDIR);
37    static ref HOME: String = std::env::var("HOME").unwrap();
38}
39static SYSCONFIG: &str = "/etc/nix-data/config.json";