Skip to content

Commit

Permalink
Revert "lint: rename nix_file::NixFileStore to nix_file::Store"
Browse files Browse the repository at this point in the history
This reverts commit 93794c4.
  • Loading branch information
willbush committed Oct 30, 2024
1 parent 8f44f5f commit 313e68a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ use relative_path::RelativePathBuf;
use serde::Deserialize;

use crate::nix_file::CallPackageArgumentInfo;
use crate::nix_file::Store;
use crate::problem::{
npv_100, npv_101, npv_102, npv_103, npv_104, npv_105, npv_106, npv_107, npv_108, npv_120,
};
use crate::ratchet::State::{Loose, Tight};
use crate::structure::{self, BASE_SUBPATH};
use crate::validation::ResultIteratorExt as _;
use crate::validation::{self, Validation::Success};
use crate::NixFileStore;
use crate::{location, ratchet};

const EVAL_NIX: &[u8] = include_bytes!("eval.nix");
Expand Down Expand Up @@ -154,7 +154,7 @@ fn mutate_nix_instatiate_arguments_based_on_cfg(
/// achieved on the Nix side.
pub fn check_values(
nixpkgs_path: &Path,
nix_file_store: &mut Store,
nix_file_store: &mut NixFileStore,
package_names: &[String],
) -> validation::Result<ratchet::Nixpkgs> {
let work_dir = tempfile::Builder::new()
Expand Down Expand Up @@ -263,7 +263,7 @@ pub fn check_values(

/// Handle the evaluation result for an attribute in `pkgs/by-name`, making it a validation result.
fn by_name(
nix_file_store: &mut Store,
nix_file_store: &mut NixFileStore,
nixpkgs_path: &Path,
attribute_name: &str,
by_name_attribute: ByNameAttribute,
Expand Down Expand Up @@ -451,7 +451,7 @@ fn by_name_override(
/// validation result.
fn handle_non_by_name_attribute(
nixpkgs_path: &Path,
nix_file_store: &mut Store,
nix_file_store: &mut NixFileStore,
attribute_name: &str,
non_by_name_attribute: NonByNameAttribute,
) -> validation::Result<ratchet::Package> {
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::path::{Path, PathBuf};
use std::process::ExitCode;
use std::{panic, thread};

use crate::nix_file::NixFileStore;
use crate::status::{ColoredStatus, Status};
use crate::validation::Validation::Failure;
use crate::validation::Validation::Success;
Expand Down Expand Up @@ -107,7 +108,7 @@ fn check_nixpkgs(nixpkgs_path: &Path) -> validation::Result<ratchet::Nixpkgs> {
return Ok(Success(ratchet::Nixpkgs::default()));
}

let mut nix_file_store = nix_file::Store::default();
let mut nix_file_store = NixFileStore::default();
let structure = structure::check(&nixpkgs_path, &mut nix_file_store)?;

// Only if we could successfully parse the structure, we do the evaluation checks
Expand Down
6 changes: 3 additions & 3 deletions src/nix_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ use std::path::PathBuf;
/// A structure to store parse results of Nix files in memory, making sure that the same file never
/// has to be parsed twice.
#[derive(Default)]
pub struct Store {
pub struct NixFileStore {
entries: HashMap<PathBuf, NixFile>,
}

impl Store {
impl NixFileStore {
/// Get the store entry for a Nix file if it exists, otherwise parse the file, insert it into
/// the store, and return the value.
///
Expand Down Expand Up @@ -116,7 +116,7 @@ impl NixFile {
///
/// results in `{ file = ./default.nix; line = 2; column = 3; }`
///
/// - Get the `NixFile` for `.file` from a `nix_file::Store`
/// - Get the `NixFile` for `.file` from a `NixFileStore`
///
/// - Call this function with `.line`, `.column` and `relative_to` as the (absolute) current
/// directory.
Expand Down
8 changes: 4 additions & 4 deletions src/references.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ use relative_path::RelativePath;
use rowan::ast::AstNode;

use crate::nix_file::ResolvedPath;
use crate::nix_file::Store;
use crate::problem::{npv_121, npv_122, npv_123, npv_124, npv_125, npv_126};
use crate::structure::read_dir_sorted;
use crate::validation::{self, ResultIteratorExt, Validation::Success};
use crate::NixFileStore;

/// Check that every package directory in pkgs/by-name doesn't link to outside that directory.
/// Both symlinks and Nix path expressions are checked.
pub fn check(
nix_file_store: &mut Store,
nix_file_store: &mut NixFileStore,
relative_package_dir: &RelativePath,
absolute_package_dir: &Path,
) -> validation::Result<()> {
Expand All @@ -40,7 +40,7 @@ pub fn check(
/// A relative path so that the error messages don't get absolute paths (which are messy in CI).
/// The absolute package directory gets prepended before doing anything with it though.
fn check_path(
nix_file_store: &mut Store,
nix_file_store: &mut NixFileStore,
relative_package_dir: &RelativePath,
absolute_package_dir: &Path,
subpath: &RelativePath,
Expand Down Expand Up @@ -111,7 +111,7 @@ fn check_path(
/// Check whether a Nix file contains path expression references pointing outside the package
/// directory.
fn check_nix_file(
nix_file_store: &mut Store,
nix_file_store: &mut NixFileStore,
relative_package_dir: &RelativePath,
absolute_package_dir: &Path,
subpath: &RelativePath,
Expand Down
6 changes: 3 additions & 3 deletions src/structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use lazy_static::lazy_static;
use regex::Regex;
use relative_path::RelativePathBuf;

use crate::nix_file::Store;
use crate::problem::{npv_109, npv_110, npv_111, npv_140, npv_141, npv_142, npv_143, npv_144};
use crate::references;
use crate::validation::{self, ResultIteratorExt, Validation::Success};
use crate::NixFileStore;

pub const BASE_SUBPATH: &str = "pkgs/by-name";
pub const PACKAGE_NIX_FILENAME: &str = "package.nix";
Expand Down Expand Up @@ -52,7 +52,7 @@ pub fn relative_file_for_package(package_name: &str) -> RelativePathBuf {

/// Check the structure of Nixpkgs, returning the attribute names that are defined in
/// `pkgs/by-name`
pub fn check(path: &Path, nix_file_store: &mut Store) -> validation::Result<Vec<String>> {
pub fn check(path: &Path, nix_file_store: &mut NixFileStore) -> validation::Result<Vec<String>> {
let base_dir = path.join(BASE_SUBPATH);

let shard_results = read_dir_sorted(&base_dir)?
Expand Down Expand Up @@ -118,7 +118,7 @@ pub fn check(path: &Path, nix_file_store: &mut Store) -> validation::Result<Vec<
}

fn check_package(
nix_file_store: &mut Store,
nix_file_store: &mut NixFileStore,
path: &Path,
shard_name: &str,
shard_name_valid: bool,
Expand Down

0 comments on commit 313e68a

Please sign in to comment.