mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-15 21:32:26 +01:00
komorebi.json is described as a JSON Schema, made from the Rust types that read it: komorebic prints the schema of komorebi.json, of an applications.json, of a notification and of a message, and the daemon answers the same four questions on its socket. schema.json and schema.asc.json are committed (just jsonschema). The module's config option is typed from the schema: schemars-nixgen makes nix/komorebi-options.nix from schema.json (just nixgen), so a layout komorebi does not have, or a value of the wrong kind, does not evaluate. The module writes config as a komorebi.json and gives it to the daemon with --config. configFile and the file the module writes are checked against the schema when the system is built. applicationSpecificConfiguration takes files from GitHub, and there are none by default, since no community file for Plasma is known. Two checks keep the generated files honest without the tools that make them. schema-fresh compares the schemas with what komorebic prints, and the hash on the first line of the options with the schema. nix-options-validation evaluates the options against the example configuration, written in Nix and in JSON. nixos-module-eval also evaluates the module with the sources turned off: with applicationSpecificConfiguration.enable = false the sources are left out of the config that is written, and with no config either there is nothing to write and the unit passes no --config. ARCHITECTURE has the guarantee row that names the two checks.
68 lines
3.0 KiB
Makefile
68 lines
3.0 KiB
Makefile
export RUST_BACKTRACE := "full"
|
|
|
|
# format the Rust sources (needs a nightly rustfmt: rustfmt.toml uses unstable options)
|
|
fmt:
|
|
cargo fmt
|
|
|
|
# everything a change has to pass before it is pushed
|
|
check: lint check-js
|
|
cargo fmt --check
|
|
cargo clippy --workspace --all-targets --locked -- -D warnings
|
|
cargo test --workspace --locked
|
|
RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --locked
|
|
|
|
# the KWin bridge, which is JavaScript: its types, checked by tsc from its JSDoc comments, and its
|
|
# tests, which node runs against a fake KWin (no package.json, no build step)
|
|
check-js:
|
|
cd komorebi/src/kwin && tsc -p tsconfig.json
|
|
node --test komorebi/src/kwin/bridge.test.js
|
|
|
|
# the macros the codebase has agreed not to use
|
|
lint:
|
|
test -z "$(rg 'eyre!' --type rust .)" || (echo "eyre! macro not allowed"; false)
|
|
test -z "$(rg 'dbg!' --type rust .)" || (echo "dbg! macro not allowed"; false)
|
|
test -z "$(rg 'println!' --type rust ./komorebi/src)" || (echo "println! macro not allowed"; false)
|
|
|
|
# the JSON Schemas of komorebi.json and of applications.json, from the Rust types
|
|
jsonschema:
|
|
cargo run --package komorebic --locked -- static-config-schema > schema.json
|
|
cargo run --package komorebic --locked -- application-specific-configuration-schema > schema.asc.json
|
|
|
|
# the options of the module's `config`, from schema.json, with the hash of the schema they were
|
|
# made from in the first line (the check `schema-fresh` compares it); needs schemars-nixgen
|
|
# (`cargo install schemars-nixgen`), which the dev shell does not have
|
|
nixgen:
|
|
schemars-nixgen schema.json -o nix/komorebi-options.nix --name komorebi --description "komorebi for KDE Plasma configuration"
|
|
printf '# schema-sha256: %s\n' "$(nix hash file --type sha256 --base16 schema.json)" | cat - nix/komorebi-options.nix > nix/komorebi-options.nix.new
|
|
mv nix/komorebi-options.nix.new nix/komorebi-options.nix
|
|
nix fmt nix/komorebi-options.nix
|
|
nix build -L --no-link ".#checks.$(nix eval --raw --impure --expr builtins.currentSystem).nix-options-validation"
|
|
|
|
# one VM test, on this machine: `just vm kwin`. Linux boots the guest under KVM through the
|
|
# flake check; a Mac builds the guest on a builder and runs the driver (see docs/dev/vm-tests.md)
|
|
vm name:
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
if [ "$(uname)" = Darwin ]; then
|
|
scripts/vm-mac {{ name }}
|
|
else
|
|
nix build -L .#checks.{{ arch() }}-linux.vm-{{ name }}
|
|
fi
|
|
|
|
# every VM test, in the order of the flake
|
|
vm-all:
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
system=$(nix eval --raw --impure --expr builtins.currentSystem)
|
|
for name in $(nix eval --json ".#legacyPackages.$system.vm" --apply builtins.attrNames | jq -r '.[]'); do
|
|
just vm "$name"
|
|
done
|
|
|
|
# write the help of every komorebic subcommand to docs/cli, one page each
|
|
docgen:
|
|
rm -f docs/cli/*.md
|
|
cargo run --package komorebic --locked -- docgen --output docs/cli
|
|
|
|
run target *args:
|
|
cargo run --bin {{ target }} --locked -- {{ args }}
|