diff --git a/pkgs/id/.editorconfig b/pkgs/id/.editorconfig new file mode 100644 index 0000000000..13f8c273bf --- /dev/null +++ b/pkgs/id/.editorconfig @@ -0,0 +1,44 @@ +# pkgs/id is a standalone flake: its checks build from a source copy of +# this directory alone, so the repository-root .editorconfig is not +# visible inside the Nix sandbox. Tools that read editorconfig +# (prettier, shfmt) therefore formatted differently in CI than in a +# working tree — e.g. prettier's markdown print width comes from the +# [*.md] max_line_length rule below (#702). Keep this file in sync +# with the root .editorconfig rules that cover files under pkgs/id. +root = true + +[*] +charset=utf-8 +end_of_line=lf +indent_size=2 +indent_style=space +insert_final_newline=true +trim_trailing_whitespace=true + +[*.{bzl, py}] +indent_size = 4 + +[*.{nix}] +indent_size = 2 + +[*.md] +max_line_length=off +trim_trailing_whitespace=false + +[doc/**/transcript.txt] +trim_trailing_whitespace = false +insert_final_newline = false +end_of_line = unset + +[*.{diff,patch}] +end_of_line=unset +indent_size=unset +insert_final_newline=unset +trim_trailing_whitespace=unset + +[{LICENSES/**,LICENSE*}] +charset=unset +end_of_line=unset +indent_size=unset +insert_final_newline=unset +trim_trailing_whitespace=unset diff --git a/pkgs/id/Cargo.toml b/pkgs/id/Cargo.toml index b9819957fd..fa5bfae38d 100644 --- a/pkgs/id/Cargo.toml +++ b/pkgs/id/Cargo.toml @@ -64,10 +64,14 @@ p2panda-sync = { path = "vendor/p2panda-sync" } # Group membership and the auth DAG (P2.1). The `serde` feature (P2.3) serializes group actions, # which the event store keeps with each group operation. `test_utils` is not enabled: it turns on # test-only behaviour in p2panda-core, so the test types come from our own tests. -p2panda-auth = { git = "https://github.com/p2panda/p2panda", rev = "3e84cac48bba05c6857cce2ec433862b97f8d53c", features = ["serde"] } +p2panda-auth = { git = "https://github.com/p2panda/p2panda", rev = "3e84cac48bba05c6857cce2ec433862b97f8d53c", features = [ + "serde", +] } # DataScheme group encryption (P4.1, src/encryption/). `data_scheme` is on because the adapter is the # scheme. `test_utils` and `message_scheme` stay off: the adapter brings its own orderer and membership. -p2panda-encryption = { path = "vendor/p2panda-encryption", default-features = false, features = ["data_scheme"] } +p2panda-encryption = { path = "vendor/p2panda-encryption", default-features = false, features = [ + "data_scheme", +] } postcard = { version = "1", features = ["alloc"] } rand = "0.10" redb = "=4.3.0" diff --git a/pkgs/id/flake.nix b/pkgs/id/flake.nix index 39353a3a95..176808a2de 100644 --- a/pkgs/id/flake.nix +++ b/pkgs/id/flake.nix @@ -410,7 +410,7 @@ src = ./.; nativeBuildInputs = fmtBins; buildPhase = '' - treefmt --config-file ./treefmt.toml --tree-root "$(pwd)" --ci 2>&1 || true + treefmt --config-file ./treefmt.toml --tree-root "$(pwd)" --ci 2>&1 ''; installPhase = '' mkdir -p $out @@ -442,8 +442,7 @@ nativeBuildInputs = [ rustToolchain ]; buildPhase = '' find . -name '*.rs' -not -path '*/target/*' \ - -exec rustfmt --check --edition 2024 {} + \ - || true + -exec rustfmt --check --edition 2024 {} + ''; installPhase = '' mkdir -p $out @@ -455,9 +454,17 @@ src = ./.; nativeBuildInputs = [ pkgs.statix ]; buildPhase = '' - find . -name '*.nix' -print0 | while IFS= read -r -d "" f; do - statix check -- "$f" || true - done + # Collect failures across files instead of swallowing each + # one: a pipe into `while` would run the loop in a subshell + # and lose the flag, so feed it via process substitution. + fail=0 + while IFS= read -r -d "" f; do + statix check -- "$f" || fail=1 + done < <(find . -name '*.nix' -print0) + if [ "$fail" -ne 0 ]; then + echo "statix-check: statix reported problems above" >&2 + false + fi ''; installPhase = '' mkdir -p $out @@ -470,8 +477,7 @@ nativeBuildInputs = [ pkgs.shfmt ]; buildPhase = '' find . -name '*.sh' -not -path '*/node_modules/*' \ - -exec shfmt -d -i 2 -s {} + \ - || true + -exec shfmt -d -i 2 -s {} + ''; installPhase = '' mkdir -p $out @@ -483,9 +489,14 @@ src = ./.; nativeBuildInputs = [ pkgs.shellcheck ]; buildPhase = '' + # Enforced at warning severity (#702): under sandbox + # conditions shellcheck reports only four info findings + # (SC2012, `ls` glob picks in the examples' build.sh + # files) and no warning-or-above findings, so warnings + # and errors fail the gate while those info findings + # are worked down separately. find . -name '*.sh' -not -path '*/node_modules/*' \ - -exec shellcheck {} + \ - || true + -exec shellcheck --severity=warning {} + ''; installPhase = '' mkdir -p $out @@ -498,8 +509,7 @@ nativeBuildInputs = [ pkgs.taplo ]; buildPhase = '' find . -name '*.toml' -not -path '*/target/*' \ - -exec taplo check {} + \ - || true + -exec taplo check {} + ''; installPhase = '' mkdir -p $out @@ -515,8 +525,7 @@ -o -name '*.scss' -o -name '*.yaml' \) \ -not -path '*/node_modules/*' -not -path '*/target/*' \ -not -path '*/dist/*' \ - -exec prettier --check {} + \ - || true + -exec prettier --check {} + ''; installPhase = '' mkdir -p $out diff --git a/pkgs/id/statix.toml b/pkgs/id/statix.toml new file mode 100644 index 0000000000..98774f4ed7 --- /dev/null +++ b/pkgs/id/statix.toml @@ -0,0 +1,9 @@ +# pkgs/id is a standalone flake: its checks build from a source copy of +# this directory alone, so the repository-root statix.toml is not +# visible inside the Nix sandbox. Without this file the sandbox run +# enables lints the project deliberately turned off — repeated_keys +# (W20) fires on the idiomatic dotted `nodes.` paths in the +# NixOS VM test files (#702). Keep in sync with the root statix.toml. +disabled = ["repeated_keys"] +nix_version = '2.23' +ignore = ['.direnv'] diff --git a/pkgs/id/treefmt.toml b/pkgs/id/treefmt.toml index 4a01ceaea7..ce4effb171 100644 --- a/pkgs/id/treefmt.toml +++ b/pkgs/id/treefmt.toml @@ -21,6 +21,8 @@ excludes = [ "web/bun.nix", "e2e/bun.nix", "flake.lock", + # Vendored upstream crates: do not reformat code we do not own (#702). + "vendor/**", ] [formatter.rustfmt]