mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-27 19:02:47 +01:00
komorebi-for-kde/nix/ -> nix/linux/ komorebi-for-mac/nix/ -> nix/macos/ The nix expressions of the platforms (modules, option files, VM test suites, kwin effects, the darwin module) sit next to the existing nix/workspace-src.nix. Renames only (252 files); the flakes that import them are replaced by one root flake later in this stack, so nix does not evaluate at this revision.
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 = ../../schema.json;
|
|
barSchemaPath = ../../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
|
|
''
|