mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-30 04:04:09 +01:00
feat(wm): JSON schemas, and the module's typed options
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.
This commit is contained in:
1 parent
ed34286bca
commit
3a3a0f8f24
29 files changed
+2754
-49
No files matched your search
@@ -99,6 +99,15 @@
|
||||
;
|
||||
komorebi = extractBinary "komorebi";
|
||||
komorebic = extractBinary "komorebic";
|
||||
# komorebic with the constant commit of the checks, whose output the schemas are
|
||||
# checked against: it is the same for every commit
|
||||
komorebicForChecks = craneLib.buildPackage (
|
||||
individualCrateArgs
|
||||
// {
|
||||
pname = "komorebic-for-checks";
|
||||
cargoExtraArgs = "--package komorebic --bin komorebic";
|
||||
}
|
||||
);
|
||||
};
|
||||
in
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
@@ -216,6 +225,30 @@
|
||||
|
||||
vm-lib = vm.lib;
|
||||
|
||||
# The schemas, the options made from one of them and the example are what the Rust types
|
||||
# say: `just jsonschema` and `just nixgen` write them
|
||||
schema-fresh =
|
||||
pkgs.runCommand "komorebi-schema-fresh"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
build.komorebicForChecks
|
||||
pkgs.diffutils
|
||||
];
|
||||
}
|
||||
''
|
||||
komorebic static-config-schema | diff -u ${./schema.json} - \
|
||||
|| { echo "schema.json is stale: run just jsonschema"; exit 1; }
|
||||
komorebic application-specific-configuration-schema | diff -u ${./schema.asc.json} - \
|
||||
|| { echo "schema.asc.json is stale: run just jsonschema"; exit 1; }
|
||||
expected=$(sha256sum ${./schema.json} | cut -d' ' -f1)
|
||||
head -n 1 ${./nix/komorebi-options.nix} | grep -qx "# schema-sha256: $expected" \
|
||||
|| { echo "nix/komorebi-options.nix is stale: run just nixgen"; exit 1; }
|
||||
touch $out
|
||||
'';
|
||||
|
||||
# the options the module is typed with, evaluated against the example configuration
|
||||
nix-options-validation = import ./nix/tests/default.nix { inherit pkgs; };
|
||||
|
||||
# The NixOS module in real NixOS systems, evaluated and never built, so a Mac checks it
|
||||
# too. A VM suite, `vm-module`, runs it.
|
||||
nixos-module-eval = import ./nix/tests/nixos-module.nix {
|
||||
@@ -282,6 +315,7 @@
|
||||
|
||||
pkgs.cargo-deny
|
||||
pkgs.cargo-nextest
|
||||
pkgs.check-jsonschema
|
||||
pkgs.jq
|
||||
pkgs.just
|
||||
pkgs.ripgrep
|
||||
|
||||
Reference in new issue
Block a user