1pub mod install;
2pub mod list;
3pub mod remove;
4pub mod update;
5
6use anyhow::{Context, Result};
7use std::process::Command;
8
9pub fn get_channel() -> Result<String> {
10 let output = Command::new("nix-channel").arg("--list").output()?;
11 let output = String::from_utf8(output.stdout)?;
12 let channel = output
13 .split("\n")
14 .collect::<Vec<_>>()
15 .iter()
16 .find(|x| x.starts_with("nixos") || x.starts_with("nixpkgs"))
17 .context("Failed to get channel")?
18 .split_whitespace()
19 .collect::<Vec<_>>()[0]
20 .to_string();
21 Ok(channel)
22}