diff --git a/flake-info/default.nix b/flake-info/default.nix index c77da28..941b0df 100644 --- a/flake-info/default.nix +++ b/flake-info/default.nix @@ -1,5 +1,4 @@ { pkgs ? import {} -, nixosChannels ? {} }: pkgs.rustPlatform.buildRustPackage rec { name = "flake-info"; @@ -34,7 +33,6 @@ pkgs.rustPlatform.buildRustPackage rec { cp -rt "$out" assets wrapProgram $out/bin/flake-info \ - --set NIXOS_CHANNELS '${builtins.toJSON nixosChannels}' \ --prefix PATH : ${pkgs.pandoc}/bin ''; } diff --git a/flake-info/src/bin/flake-info.rs b/flake-info/src/bin/flake-info.rs index 3183fe3..c265af7 100644 --- a/flake-info/src/bin/flake-info.rs +++ b/flake-info/src/bin/flake-info.rs @@ -3,13 +3,10 @@ use flake_info::commands::NixCheckError; use flake_info::data::import::Kind; use flake_info::data::{self, Export, Source}; use flake_info::elastic::{self, ElasticsearchError, ExistsStrategy}; -use lazy_static::lazy_static; use log::{error, info, warn}; -use serde::Deserialize; use sha2::Digest; use std::io; use std::path::PathBuf; -use std::str::FromStr; use structopt::{clap::ArgGroup, StructOpt}; use thiserror::Error; use tokio::fs::File; @@ -190,9 +187,6 @@ enum FlakeInfoError { #[error("Nix check failed: {0}")] NixCheck(#[from] NixCheckError), - #[error("Nixos Channel `{0}` not among the allowed Channels set by NIXOS_CHANNELS ({:?}", .1.channels)] - UnknownNixOSChannel(String, NixosChannels), - #[error("Getting flake info caused an error: {0:?}")] Flake(anyhow::Error), #[error("Getting nixpkgs info caused an error: {0:?}")] @@ -225,8 +219,6 @@ async fn run_command( Ok((exports, ident)) } Command::Nixpkgs { channel } => { - NIXOS_CHANNELS.check_channel(&channel)?; - let nixpkgs = Source::nixpkgs(channel) .await .map_err(FlakeInfoError::Nixpkgs)?; @@ -241,8 +233,6 @@ async fn run_command( Ok((exports, ident)) } Command::NixpkgsArchive { source, channel } => { - NIXOS_CHANNELS.check_channel(&channel)?; - let ident = ( "nixos".to_string(), channel.to_owned(), @@ -397,48 +387,3 @@ async fn push_to_elastic( Ok(()) } - -/// Information about allowed and default nixos channels. -/// Typyically passed by environment variable NIXOS_CHANNELS. -/// Used to filter the input arguments for `flake-info nixpkgs` and `flake-info nixpkgs-archive` -#[derive(Clone, Debug, Deserialize)] -struct NixosChannels { - channels: Vec, -} - -#[derive(Clone, Debug, Deserialize)] -struct Channel { - branch: String, -} - -impl NixosChannels { - fn check_channel(&self, channel: &String) -> Result<(), FlakeInfoError> { - self.channels - .iter() - .find(|c| &c.branch == channel) - .map_or_else( - || Ok(()), - |_| { - Err(FlakeInfoError::UnknownNixOSChannel( - channel.clone(), - self.clone(), - )) - }, - ) - } -} - -impl FromStr for NixosChannels { - type Err = serde_json::Error; - - fn from_str(s: &str) -> Result { - serde_json::from_str(s) - } -} - -lazy_static! { - static ref NIXOS_CHANNELS: NixosChannels = std::env::var("NIXOS_CHANNELS") - .unwrap_or("".to_string()) - .parse() - .unwrap(); -} diff --git a/flake.nix b/flake.nix index 481038c..f841fc4 100644 --- a/flake.nix +++ b/flake.nix @@ -85,7 +85,7 @@ in rec { packages.default = packages.flake-info; - packages.flake-info = import ./flake-info { inherit pkgs nixosChannels; }; + packages.flake-info = import ./flake-info { inherit pkgs; }; packages.frontend = import ./frontend { inherit pkgs nixosChannels version; }; packages.nixosChannels = nixosChannelsFile;