mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-15 13:22:19 +01:00
The pure moves put the KDE and macOS nix files under nix/linux and nix/macos but left the relative paths they read: the JSON schema (now schemas/linux and schemas/macos), the example configurations and key binding samples (docs/linux, docs/macos), the key binding fixtures (komorebi-hotkeys at the top level), the wsl2 probe script (scripts/linux). Each path now names the file in the final directory, one more directory up because the files are one level deeper. Not touched: flake.nix and the nested flakes (next revisions), which still name the old paths. Verified: not verified (nothing evaluates until the flake is rewritten; the new flake checks these paths).
74 lines
2.2 KiB
Nix
74 lines
2.2 KiB
Nix
# E2E test harness for validating generated Nix options
|
|
# run with: nix build -f nix/tests/default.nix
|
|
# or via flake: nix flake check (runs as part of checks)
|
|
{
|
|
pkgs ? import <nixpkgs> { },
|
|
}:
|
|
let
|
|
lib = pkgs.lib;
|
|
|
|
# recursively filter out null values and empty attrs from a config
|
|
# this is needed because the Nix module system uses null for unset optional fields,
|
|
# but the JSON schema expects those fields to be absent entirely
|
|
filterNulls =
|
|
value:
|
|
if value == null then
|
|
null
|
|
else if builtins.isList value then
|
|
map filterNulls (builtins.filter (x: x != null) value)
|
|
else if builtins.isAttrs value then
|
|
let
|
|
filtered = lib.filterAttrs (_n: v: v != null) (builtins.mapAttrs (_n: v: filterNulls v) value);
|
|
in
|
|
filtered
|
|
else
|
|
value;
|
|
|
|
evalConfig =
|
|
optionsModule: configModule: configPath:
|
|
let
|
|
evaluated = lib.evalModules {
|
|
modules = [
|
|
optionsModule
|
|
configModule
|
|
];
|
|
};
|
|
rawConfig = lib.getAttrFromPath configPath evaluated.config;
|
|
in
|
|
filterNulls rawConfig;
|
|
|
|
komorebiOptions = import ../komorebi-options.nix;
|
|
komorebiBarOptions = import ../komorebi-bar-options.nix;
|
|
|
|
komorebiExample = import ./komorebi-example.nix;
|
|
komorebiBarExample = import ./komorebi-bar-example.nix;
|
|
|
|
configs = {
|
|
komorebi-example = evalConfig komorebiOptions komorebiExample [ "komorebi" ];
|
|
komorebi-bar-example = evalConfig komorebiBarOptions komorebiBarExample [ "komorebi-bar" ];
|
|
};
|
|
|
|
komorebiJson = pkgs.writeText "komorebi-example.json" (builtins.toJSON configs.komorebi-example);
|
|
komorebiBarJson = pkgs.writeText "komorebi-bar-example.json" (
|
|
builtins.toJSON configs.komorebi-bar-example
|
|
);
|
|
|
|
schemaPath = ../../../schemas/macos/schema.json;
|
|
barSchemaPath = ../../../schemas/macos/schema.bar.json;
|
|
|
|
in
|
|
pkgs.runCommand "nix-options-validation"
|
|
{
|
|
nativeBuildInputs = [ pkgs.check-jsonschema ];
|
|
}
|
|
''
|
|
echo "Validating komorebi config against schema..."
|
|
check-jsonschema --schemafile ${schemaPath} ${komorebiJson}
|
|
|
|
echo "Validating komorebi-bar config against schema..."
|
|
check-jsonschema --schemafile ${barSchemaPath} ${komorebiBarJson}
|
|
|
|
echo "All validations passed!"
|
|
touch $out
|
|
''
|