diff --git a/AGENTS.md b/AGENTS.md index 3043e9b..05a4030 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -105,7 +105,7 @@ Do not use `nix fmt` as a validation command until a formatter is added. - The `fix` app passes its current directory to Deadnix. Run `nix run .#fix` from the repository root so path exclusions match. -- During the Nix refactor, address each issue that comes up by adding either a Xatu rule or a new Nix style rule. +- During the Nix refactor, address each issue that comes up by adding either a Natu rule or a new Nix style rule. - Git pathspec searches started in a subdirectory default to that subtree. Use `git -C ` or top-anchored pathspecs for repository-wide history searches. - Ariadne extraction must preserve the game-root season prefix for archived source. diff --git a/Cargo.lock b/Cargo.lock index bedb295..7203c1f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -190,6 +190,18 @@ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" name = "monorepo" version = "0.1.0" +[[package]] +name = "natu" +version = "0.1.0" +dependencies = [ + "clap", + "googletest", + "monorepo", + "rnix", + "rowan", + "status", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -393,18 +405,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "xatu" -version = "0.1.0" -dependencies = [ - "clap", - "googletest", - "monorepo", - "rnix", - "rowan", - "status", -] - [[package]] name = "zmij" version = "1.0.23" diff --git a/Cargo.toml b/Cargo.toml index 70160ad..a9e1b62 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = [ "src/machoke", "src/monorepo", "src/status", - "src/xatu", + "src/natu", ] resolver = "3" diff --git a/MODULE.bazel b/MODULE.bazel index 85ede7d..8f6add4 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -14,4 +14,5 @@ rust = use_extension("//bazel:rust.bzl", "rust") use_repo(rust, "rust") register_toolchains("@python//:python") + register_toolchains("@rust//:rust") diff --git a/docs/TODO.md b/docs/TODO.md index 536bc01..853b804 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -3,7 +3,7 @@ - machoke - falinks - dotfiles -- xatu +- natu - nix-style / refactor # project ideas @@ -100,7 +100,7 @@ - https://www.youtube.com/watch?v=kzcI5F4tGiU - https://www.youtube.com/watch?v=iKwPaB5TUdI - https://www.youtube.com/watch?v=A-CtdQFRX64 -- xatu literature +- natu literature - https://rust-analyzer.github.io/book/contributing/syntax.html?utm_source=chatgpt.com - https://github.com/dotnet/roslyn/blob/main/docs/compilers/Design/Red-Green%20Trees.md?utm_source=chatgpt.com - https://github.com/rust-analyzer/rowan/blob/master/examples/s_expressions.rs?utm_source=chatgpt.com diff --git a/src/flake/apps.nix b/src/flake/apps.nix index 321cdb3..35777a3 100644 --- a/src/flake/apps.nix +++ b/src/flake/apps.nix @@ -24,7 +24,7 @@ in configs/nixos/hosts/neogaia/hardware-configuration.nix \ configs/nixos/hosts/pikachu/hardware-configuration.nix \ configs/nixos/hosts/zeus/hardware-configuration.nix \ - src/xatu/testdata \ + src/natu/testdata \ third_party \ -- . treefmt diff --git a/src/flake/formatter.nix b/src/flake/formatter.nix index 632ecf2..737906c 100644 --- a/src/flake/formatter.nix +++ b/src/flake/formatter.nix @@ -6,7 +6,7 @@ inputs.treefmt-nix.lib.evalModule inputs.nixpkgs.legacyPackages.${system} { settings.formatter.nixfmt.excludes = [ "configs/nixos/hosts/*/hardware-configuration.nix" - "src/xatu/testdata/*.nix" + "src/natu/testdata/*.nix" "third_party/**" ]; } diff --git a/src/xatu/BUILD b/src/natu/BUILD similarity index 78% rename from src/xatu/BUILD rename to src/natu/BUILD index 0ca6ac7..40c8de6 100644 --- a/src/xatu/BUILD +++ b/src/natu/BUILD @@ -1,11 +1,12 @@ load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test") rust_library( - name = "xatu_lib", - crate_name = "xatu", + name = "natu_lib", + crate_name = "natu", srcs = [ "ast.rs", "file_store.rs", + "natu.rs", "parser.rs", "rules.rs", "rules/let_order.rs", @@ -13,7 +14,6 @@ rust_library( "rules/manual_inherit_from.rs", "rules/unquoted_uri.rs", "scope_graph.rs", - "xatu.rs", ], deps = [ "//src/status:status", @@ -25,30 +25,30 @@ rust_library( rust_test( name = "file_store_test", srcs = ["file_store_test.rs"], - deps = [":xatu_lib"], + deps = [":natu_lib"], ) rust_test( - name = "xatu_test", - srcs = ["xatu_test.rs"], + name = "natu_test", + srcs = ["natu_test.rs"], data = [ "testdata/clean.nix", "testdata/invalid.nix", "testdata/lint_findings.nix", ], deps = [ - ":xatu_lib", + ":natu_lib", "//src/status:status", "//third_party/crates:googletest", ], ) rust_binary( - name = "xatu", - crate_name = "xatu_cli", - srcs = ["xatu_main.rs"], + name = "natu", + crate_name = "natu_cli", + srcs = ["natu_main.rs"], deps = [ - ":xatu_lib", + ":natu_lib", "//src/monorepo:monorepo", "//src/status:status", "//third_party/crates:clap", diff --git a/src/xatu/Cargo.toml b/src/natu/Cargo.toml similarity index 81% rename from src/xatu/Cargo.toml rename to src/natu/Cargo.toml index d12e186..4899ceb 100644 --- a/src/xatu/Cargo.toml +++ b/src/natu/Cargo.toml @@ -1,14 +1,14 @@ [package] -name = "xatu" +name = "natu" version = "0.1.0" edition = "2024" [lib] -path = "xatu.rs" +path = "natu.rs" [[bin]] -name = "xatu" -path = "xatu_main.rs" +name = "natu" +path = "natu_main.rs" [dependencies] clap = { workspace = true, features = ["derive"] } diff --git a/src/xatu/ast.rs b/src/natu/ast.rs similarity index 100% rename from src/xatu/ast.rs rename to src/natu/ast.rs diff --git a/src/xatu/file_store.rs b/src/natu/file_store.rs similarity index 100% rename from src/xatu/file_store.rs rename to src/natu/file_store.rs diff --git a/src/xatu/file_store_test.rs b/src/natu/file_store_test.rs similarity index 95% rename from src/xatu/file_store_test.rs rename to src/natu/file_store_test.rs index faa9d04..eea4302 100644 --- a/src/xatu/file_store_test.rs +++ b/src/natu/file_store_test.rs @@ -1,6 +1,6 @@ use std::path::PathBuf; -use xatu::{FileStore, SourceFile}; +use natu::{FileStore, SourceFile}; fn source_file(path: &str, source: &str) -> SourceFile { SourceFile { diff --git a/src/xatu/xatu.rs b/src/natu/natu.rs similarity index 96% rename from src/xatu/xatu.rs rename to src/natu/natu.rs index f718d89..d942ea5 100644 --- a/src/xatu/xatu.rs +++ b/src/natu/natu.rs @@ -53,7 +53,7 @@ fn line_range(source: &str, range: ast::SourceRange) -> (usize, usize) { (start, end) } -/// Analyzes source files and returns the diagnostics Xatu finds. +/// Analyzes source files and returns the diagnostics Natu finds. pub fn future_sight(files: Vec) -> status::Result { let mut store = FileStore::default(); let mut diagnostics = Vec::new(); diff --git a/src/xatu/xatu_main.rs b/src/natu/natu_main.rs similarity index 97% rename from src/xatu/xatu_main.rs rename to src/natu/natu_main.rs index 256984d..2042f96 100644 --- a/src/xatu/xatu_main.rs +++ b/src/natu/natu_main.rs @@ -1,8 +1,8 @@ use clap::Parser; +use natu::{Report, SourceFile}; use status::ResultExt; use std::path::{Path, PathBuf}; use std::process::ExitCode; -use xatu::{Report, SourceFile}; fn main() -> ExitCode { let args = Args::parse(); @@ -44,7 +44,7 @@ fn analyze(args: Args) -> status::Result { .flatten() .collect(); - xatu::future_sight(files) + natu::future_sight(files) } fn collect_source_files(path: &Path) -> status::Result> { diff --git a/src/xatu/xatu_test.rs b/src/natu/natu_test.rs similarity index 72% rename from src/xatu/xatu_test.rs rename to src/natu/natu_test.rs index 66ebd71..45087bd 100644 --- a/src/xatu/xatu_test.rs +++ b/src/natu/natu_test.rs @@ -3,7 +3,7 @@ use std::path::{Path, PathBuf}; use googletest::matchers::{contains, eq, is_true}; use googletest::{OrFail, expect_that, gtest}; use status::Code; -use xatu::SourceFile; +use natu::SourceFile; fn fixture_source(path: &str) -> googletest::Result { Ok(SourceFile { @@ -20,20 +20,20 @@ fn fixture_path(path: &str) -> googletest::Result { let runfiles = PathBuf::from(std::env::var("TEST_SRCDIR").or_fail()?); let workspace = std::env::var("TEST_WORKSPACE").or_fail()?; - Ok(runfiles.join(workspace).join("src/xatu").join(path)) + Ok(runfiles.join(workspace).join("src/natu").join(path)) } #[gtest] -fn xatu_accepts_clean_source() -> googletest::Result<()> { - let report = xatu::future_sight(vec![fixture_source("testdata/clean.nix")?]).or_fail()?; +fn natu_accepts_clean_source() -> googletest::Result<()> { + let report = natu::future_sight(vec![fixture_source("testdata/clean.nix")?]).or_fail()?; expect_that!(report.is_clean(), is_true()); Ok(()) } #[gtest] -fn xatu_rejects_invalid_source() -> googletest::Result<()> { - let error = xatu::future_sight(vec![fixture_source("testdata/invalid.nix")?]) +fn natu_rejects_invalid_source() -> googletest::Result<()> { + let error = natu::future_sight(vec![fixture_source("testdata/invalid.nix")?]) .err() .or_fail()?; @@ -42,8 +42,8 @@ fn xatu_rejects_invalid_source() -> googletest::Result<()> { } #[gtest] -fn xatu_reports_out_of_order_let_bindings() -> googletest::Result<()> { - let report = xatu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?; +fn natu_reports_out_of_order_let_bindings() -> googletest::Result<()> { + let report = natu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?; let let_order_count = report .diagnostics @@ -55,8 +55,8 @@ fn xatu_reports_out_of_order_let_bindings() -> googletest::Result<()> { } #[gtest] -fn xatu_reports_unquoted_uri() -> googletest::Result<()> { - let report = xatu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?; +fn natu_reports_unquoted_uri() -> googletest::Result<()> { + let report = natu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?; let findings = report .diagnostics @@ -79,8 +79,8 @@ fn xatu_reports_unquoted_uri() -> googletest::Result<()> { } #[gtest] -fn xatu_reports_manual_inherit() -> googletest::Result<()> { - let report = xatu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?; +fn natu_reports_manual_inherit() -> googletest::Result<()> { + let report = natu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?; let manual_inherit_count = report .diagnostics @@ -92,8 +92,8 @@ fn xatu_reports_manual_inherit() -> googletest::Result<()> { } #[gtest] -fn xatu_reports_manual_inherit_from() -> googletest::Result<()> { - let report = xatu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?; +fn natu_reports_manual_inherit_from() -> googletest::Result<()> { + let report = natu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?; let manual_inherit_from_count = report .diagnostics diff --git a/src/xatu/parser.rs b/src/natu/parser.rs similarity index 100% rename from src/xatu/parser.rs rename to src/natu/parser.rs diff --git a/src/xatu/rules.rs b/src/natu/rules.rs similarity index 100% rename from src/xatu/rules.rs rename to src/natu/rules.rs diff --git a/src/xatu/rules/let_order.rs b/src/natu/rules/let_order.rs similarity index 100% rename from src/xatu/rules/let_order.rs rename to src/natu/rules/let_order.rs diff --git a/src/xatu/rules/manual_inherit.rs b/src/natu/rules/manual_inherit.rs similarity index 100% rename from src/xatu/rules/manual_inherit.rs rename to src/natu/rules/manual_inherit.rs diff --git a/src/xatu/rules/manual_inherit_from.rs b/src/natu/rules/manual_inherit_from.rs similarity index 100% rename from src/xatu/rules/manual_inherit_from.rs rename to src/natu/rules/manual_inherit_from.rs diff --git a/src/xatu/rules/unquoted_uri.rs b/src/natu/rules/unquoted_uri.rs similarity index 100% rename from src/xatu/rules/unquoted_uri.rs rename to src/natu/rules/unquoted_uri.rs diff --git a/src/xatu/scope_graph.rs b/src/natu/scope_graph.rs similarity index 100% rename from src/xatu/scope_graph.rs rename to src/natu/scope_graph.rs diff --git a/src/xatu/testdata/clean.nix b/src/natu/testdata/clean.nix similarity index 100% rename from src/xatu/testdata/clean.nix rename to src/natu/testdata/clean.nix diff --git a/src/xatu/testdata/invalid.nix b/src/natu/testdata/invalid.nix similarity index 100% rename from src/xatu/testdata/invalid.nix rename to src/natu/testdata/invalid.nix diff --git a/src/xatu/testdata/lint_findings.nix b/src/natu/testdata/lint_findings.nix similarity index 100% rename from src/xatu/testdata/lint_findings.nix rename to src/natu/testdata/lint_findings.nix diff --git a/third_party/crates/crates.bzl b/third_party/crates/crates.bzl index b6d2518..7f725e1 100644 --- a/third_party/crates/crates.bzl +++ b/third_party/crates/crates.bzl @@ -314,8 +314,8 @@ _CRATE_EDITIONS = { "src/ariadne": "2024", "src/machoke": "2024", "src/monorepo": "2024", + "src/natu": "2024", "src/status": "2024", - "src/xatu": "2024", } _NORMAL_DEPENDENCIES = { @@ -335,15 +335,15 @@ _NORMAL_DEPENDENCIES = { }, "src/monorepo": { }, - "src/status": { - }, - "src/xatu": { + "src/natu": { _COMMON_CONDITION: { "clap": Label("//third_party/crates/clap-4.6.7:clap"), "rnix": Label("//third_party/crates/rnix-0.14.0:rnix"), "rowan": Label("//third_party/crates/rowan-0.16.1:rowan"), }, }, + "src/status": { + }, } _NORMAL_ALIASES = { @@ -359,12 +359,12 @@ _NORMAL_ALIASES = { }, "src/monorepo": { }, - "src/status": { - }, - "src/xatu": { + "src/natu": { _COMMON_CONDITION: { }, }, + "src/status": { + }, } _NORMAL_DEV_DEPENDENCIES = { @@ -376,13 +376,13 @@ _NORMAL_DEV_DEPENDENCIES = { }, "src/monorepo": { }, - "src/status": { - }, - "src/xatu": { + "src/natu": { _COMMON_CONDITION: { "googletest": Label("//third_party/crates/googletest-0.14.3:googletest"), }, }, + "src/status": { + }, } _NORMAL_DEV_ALIASES = { @@ -394,12 +394,12 @@ _NORMAL_DEV_ALIASES = { }, "src/monorepo": { }, - "src/status": { - }, - "src/xatu": { + "src/natu": { _COMMON_CONDITION: { }, }, + "src/status": { + }, } _PROC_MACRO_DEPENDENCIES = { @@ -411,9 +411,9 @@ _PROC_MACRO_DEPENDENCIES = { }, "src/monorepo": { }, - "src/status": { + "src/natu": { }, - "src/xatu": { + "src/status": { }, } @@ -426,9 +426,9 @@ _PROC_MACRO_ALIASES = { }, "src/monorepo": { }, - "src/status": { + "src/natu": { }, - "src/xatu": { + "src/status": { }, } @@ -441,9 +441,9 @@ _PROC_MACRO_DEV_DEPENDENCIES = { }, "src/monorepo": { }, - "src/status": { + "src/natu": { }, - "src/xatu": { + "src/status": { }, } @@ -456,12 +456,12 @@ _PROC_MACRO_DEV_ALIASES = { }, "src/monorepo": { }, - "src/status": { - }, - "src/xatu": { + "src/natu": { _COMMON_CONDITION: { }, }, + "src/status": { + }, } _BUILD_DEPENDENCIES = { @@ -473,9 +473,9 @@ _BUILD_DEPENDENCIES = { }, "src/monorepo": { }, - "src/status": { + "src/natu": { }, - "src/xatu": { + "src/status": { }, } @@ -488,9 +488,9 @@ _BUILD_ALIASES = { }, "src/monorepo": { }, - "src/status": { + "src/natu": { }, - "src/xatu": { + "src/status": { }, } @@ -503,9 +503,9 @@ _BUILD_PROC_MACRO_DEPENDENCIES = { }, "src/monorepo": { }, - "src/status": { + "src/natu": { }, - "src/xatu": { + "src/status": { }, } @@ -518,9 +518,9 @@ _BUILD_PROC_MACRO_ALIASES = { }, "src/monorepo": { }, - "src/status": { + "src/natu": { }, - "src/xatu": { + "src/status": { }, }