mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-30 12:14:10 +01:00
refactor(nix): the checks are separate sets
Every platform module now defines its checks as allChecks.<name> and the new nix/checks.nix says which set each is in (fmt, deny, windows-lint, windows-test, linux-lint, linux-test, linux-options, macos-lint, macos-test, macos-options, linux-demo, linux-nixos-eval, vm-fast, vm-slow; the vm tiers come from the suites). A check in no set, or in two, fails the evaluation. checks.<system> holds the members of the sets that are not heavy, the same split flake-one made (vm-*, the Plasma guests, the module scenarios and run-kde left out), and the placeholder legacyPackages.<system>.heavyChecks is gone: every set is one linkFarm derivation, legacyPackages.<system>.checkSets.<set>, and its members are legacyPackages.<system>.checkMembers.<set>.<name>. legacyPackages.<system>.vm is unchanged. The linux module is mostly reindented (the split wrapper is gone); no check changed. Verified: see the revision that composes the sets. treefmt and pre-commit, which the treefmt-nix and git-hooks-nix modules add to checks themselves, are allChecks of nix/common.nix now (those modules' own entries are switched off, treefmt.flakeCheck and pre-commit.check.enable), so that they are members of the set fmt.
This commit is contained in:
1 parent
22d2e1ae78
commit
6038e53fc5
6 files changed
+399
-286
No files matched your search
@@ -30,6 +30,7 @@
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
imports = [
|
||||
./nix/common.nix
|
||||
./nix/checks.nix
|
||||
./nix/windows/flake-module.nix
|
||||
./nix/linux/flake-module.nix
|
||||
./nix/macos/flake-module.nix
|
||||
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
# The checks of the flake as separate sets.
|
||||
#
|
||||
# The platform modules (nix/{windows,linux,macos}/flake-module.nix) define their checks as
|
||||
# `allChecks.<name>`; this module says which SET each one is in and builds from that
|
||||
#
|
||||
# legacyPackages.<system>.checkSets.<set> one derivation per set: a linkFarm that builds its members
|
||||
# legacyPackages.<system>.checkMembers.<set> the members of a set, one derivation each
|
||||
# checks.<system> the members of the sets that heavyCheckSets does not name
|
||||
#
|
||||
# so `nix build .#checkSets.linux-lint` builds one set and evaluates nothing else, and `nix flake check`
|
||||
# evaluates only what `checks` has. See docs/dev/flake-checks.md.
|
||||
{ lib, ... }:
|
||||
let
|
||||
# The checks of each set, by name: a name that a system does not have (the macOS checks on Linux)
|
||||
# is not a member there. A check that is in no set, or in two, is an error (below).
|
||||
sets = {
|
||||
fmt = [
|
||||
"treefmt"
|
||||
"pre-commit"
|
||||
"windows-fmt"
|
||||
"windows-toml-fmt"
|
||||
"linux-fmt"
|
||||
"linux-toml-fmt"
|
||||
"macos-fmt"
|
||||
"macos-toml-fmt"
|
||||
];
|
||||
deny = [
|
||||
"windows-deny"
|
||||
"linux-deny"
|
||||
"macos-deny"
|
||||
];
|
||||
windows-lint = [ "windows-clippy" ];
|
||||
windows-test = [
|
||||
"windows-nextest"
|
||||
"windows-e2e-tests"
|
||||
];
|
||||
linux-lint = [
|
||||
"linux-clippy"
|
||||
"linux-doc"
|
||||
];
|
||||
linux-test = [
|
||||
"linux-nextest"
|
||||
"linux-bridge-js"
|
||||
"linux-keybindings-fixtures"
|
||||
"linux-wsl2-probe"
|
||||
"linux-wsl2-probe-dry-run"
|
||||
"linux-kde-rounded-corners-komorebi-install"
|
||||
"linux-kwin-effect-geometry-change-komorebi-install"
|
||||
"vm-lib"
|
||||
];
|
||||
linux-options = [
|
||||
"linux-nix-options-validation"
|
||||
"linux-schema-fresh"
|
||||
];
|
||||
macos-lint = [ "macos-clippy" ];
|
||||
macos-test = [ "macos-nextest" ];
|
||||
macos-options = [
|
||||
"macos-nix-options-validation"
|
||||
"macos-darwin-module-validation"
|
||||
];
|
||||
# the demo guest of `run-kde` is instantiated to check the command: about 1.5 GB to evaluate
|
||||
linux-demo = [
|
||||
"linux-run-kde"
|
||||
"linux-run-kde-doctor"
|
||||
"linux-run-kde-dry-run"
|
||||
];
|
||||
# about 10 GB each to evaluate: tens of NixOS systems
|
||||
linux-nixos-eval = [
|
||||
"linux-nixos-module-eval"
|
||||
"linux-plasma-guests-eval"
|
||||
];
|
||||
};
|
||||
|
||||
# the sets sized by what is on the system: the VM suites of each tier (nix/linux/tests/vm)
|
||||
suiteSets =
|
||||
tiers:
|
||||
lib.mapAttrs' (tier: names: lib.nameValuePair "vm-${tier}" (map (name: "vm-${name}") names)) tiers;
|
||||
|
||||
# the sets that `nix flake check` does not run: evaluating their members takes more memory than a
|
||||
# check of the repository should (docs/dev/flake-checks.md has the numbers)
|
||||
heavyCheckSets = [
|
||||
"linux-demo"
|
||||
"linux-nixos-eval"
|
||||
"vm-fast"
|
||||
"vm-slow"
|
||||
];
|
||||
in
|
||||
{
|
||||
perSystem =
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
allChecks = config.allChecks;
|
||||
# the VM suites exist where `vmTiers` does (the Linux systems and Apple silicon)
|
||||
tiers = config.legacyPackages.vmTiers or { };
|
||||
namesOf = lib.attrsets.recursiveUpdate sets (suiteSets tiers);
|
||||
# the members of a set on this system
|
||||
members = lib.mapAttrs (
|
||||
_: names: lib.getAttrs (builtins.filter (name: allChecks ? ${name}) names) allChecks
|
||||
) namesOf;
|
||||
nonEmpty = lib.filterAttrs (_: ms: ms != { }) members;
|
||||
|
||||
placed = lib.concatLists (lib.attrValues (lib.mapAttrs (_: lib.attrNames) members));
|
||||
unplaced = builtins.filter (name: !(builtins.elem name placed)) (lib.attrNames allChecks);
|
||||
twice = lib.filter (name: builtins.length (lib.filter (n: n == name) placed) > 1) placed;
|
||||
mustBeInOneSet = lib.assertMsg (unplaced == [ ] && twice == [ ]) (
|
||||
"every check is in exactly one set of nix/checks.nix; in none: ${toString unplaced}; in several: ${toString twice}"
|
||||
);
|
||||
in
|
||||
{
|
||||
options.allChecks = lib.mkOption {
|
||||
type = lib.types.lazyAttrsOf lib.types.raw;
|
||||
default = { };
|
||||
description = "Every check of the system by name, whichever set it is in.";
|
||||
};
|
||||
|
||||
config = {
|
||||
checks = assert mustBeInOneSet;
|
||||
lib.concatMapAttrs (set: ms: if builtins.elem set heavyCheckSets then { } else ms) nonEmpty;
|
||||
|
||||
legacyPackages = {
|
||||
checkMembers = nonEmpty;
|
||||
checkSets = lib.mapAttrs (
|
||||
set: ms:
|
||||
pkgs.linkFarm "checks-${set}" (lib.mapAttrsToList (name: path: { inherit name path; }) ms)
|
||||
) nonEmpty;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
+9
-1
@@ -168,6 +168,7 @@ in
|
||||
{
|
||||
treefmt = {
|
||||
projectRootFile = "flake.nix";
|
||||
flakeCheck = false;
|
||||
programs = {
|
||||
deadnix.enable = true;
|
||||
just.enable = true;
|
||||
@@ -194,8 +195,15 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
# the two checks of these modules are members of the set `fmt` (nix/checks.nix), which adds them
|
||||
# to `checks` itself: the modules' own `checks` entries are off
|
||||
allChecks = {
|
||||
treefmt = config.treefmt.build.check config.treefmt.projectRoot;
|
||||
pre-commit = config.pre-commit.settings.run;
|
||||
};
|
||||
|
||||
pre-commit = {
|
||||
check.enable = true;
|
||||
check.enable = false;
|
||||
settings.hooks.treefmt = {
|
||||
enable = true;
|
||||
package = config.treefmt.build.wrapper;
|
||||
|
||||
+254
-283
@@ -77,298 +77,269 @@ in
|
||||
# rustfmt.toml uses options only a nightly rustfmt knows
|
||||
nightlyRustfmt = pkgs.rust-bin.nightly.latest.rustfmt;
|
||||
checkSystem = builtins.elem system lib'.linuxCheckSystems;
|
||||
|
||||
# PLACEHOLDER until the structure of the check sets is decided (agent flake-checks): the checks that
|
||||
# evaluate a NixOS system or a VM (vm-*, the Plasma guests, the module option tests, run-kde) take
|
||||
# minutes and many GB to evaluate, so `nix flake check --no-build --all-systems` cannot hold them. They
|
||||
# are `legacyPackages.<system>.heavyChecks.<name>` (same names as before), not `checks.<system>`.
|
||||
isHeavy =
|
||||
name:
|
||||
lib.hasPrefix "vm-" name
|
||||
|| builtins.elem name [
|
||||
"linux-nixos-module-eval"
|
||||
"linux-plasma-guests-eval"
|
||||
"linux-run-kde"
|
||||
"linux-run-kde-doctor"
|
||||
"linux-run-kde-dry-run"
|
||||
];
|
||||
split =
|
||||
r:
|
||||
if r ? allChecks then
|
||||
removeAttrs r [ "allChecks" ]
|
||||
// {
|
||||
checks = lib.filterAttrs (n: _: !isHeavy n) r.allChecks;
|
||||
legacyPackages = r.legacyPackages // {
|
||||
heavyChecks = lib.filterAttrs (n: _: isHeavy n) r.allChecks;
|
||||
};
|
||||
}
|
||||
else
|
||||
r;
|
||||
in
|
||||
split (
|
||||
lib.optionalAttrs checkSystem {
|
||||
allChecks = {
|
||||
# tools/format-all: the nightly rustfmt over the files of the Linux source, file by file. `cargo fmt`
|
||||
# followed `mod windows;` of the shared entry files into files this source does not have.
|
||||
linux-fmt =
|
||||
pkgs.runCommand "komorebi-linux-fmt"
|
||||
{
|
||||
nativeBuildInputs = [ nightlyRustfmt ];
|
||||
}
|
||||
''
|
||||
RUSTFMT=rustfmt bash ${lib'.repoFile "tools/format-all"} --check --root ${build.real}
|
||||
touch $out
|
||||
'';
|
||||
|
||||
linux-clippy = build.craneLib.cargoClippy (
|
||||
build.individualCrateArgs
|
||||
// {
|
||||
cargoClippyExtraArgs = "--all-targets -- -D warnings";
|
||||
lib.optionalAttrs checkSystem {
|
||||
allChecks = {
|
||||
# tools/format-all: the nightly rustfmt over the files of the Linux source, file by file. `cargo fmt`
|
||||
# followed `mod windows;` of the shared entry files into files this source does not have.
|
||||
linux-fmt =
|
||||
pkgs.runCommand "komorebi-linux-fmt"
|
||||
{
|
||||
nativeBuildInputs = [ nightlyRustfmt ];
|
||||
}
|
||||
);
|
||||
|
||||
linux-doc = build.craneLib.cargoDoc (
|
||||
build.individualCrateArgs
|
||||
// {
|
||||
cargoDocExtraArgs = "--no-deps";
|
||||
env.RUSTDOCFLAGS = "-D warnings";
|
||||
}
|
||||
);
|
||||
|
||||
linux-toml-fmt = build.craneLib.taploFmt (
|
||||
build.workspaceArgs
|
||||
// {
|
||||
src = lib.sources.sourceFilesBySuffices build.real [ ".toml" ];
|
||||
}
|
||||
);
|
||||
|
||||
# cargo deny sees every member of the workspace: leave out the other platforms' packages (stubs
|
||||
# here); the policy is the one deny.toml of the repository
|
||||
linux-deny = build.craneLib.cargoDeny (
|
||||
build.workspaceArgs
|
||||
// {
|
||||
inherit (build) src;
|
||||
cargoDenyExtraArgs =
|
||||
"--workspace " + lib.concatMapStringsSep " " (p: "--exclude ${p}") build.stubbedPackages;
|
||||
cargoDenyChecks = "bans licenses sources";
|
||||
}
|
||||
);
|
||||
|
||||
linux-nextest = build.craneLib.cargoNextest (build.individualCrateArgs // { doCheck = true; });
|
||||
|
||||
# The bridge is not Rust: tsc checks its types from its JSDoc comments, and node runs
|
||||
# its tests against a fake KWin. No package.json and no build step.
|
||||
linux-bridge-js =
|
||||
pkgs.runCommand "komorebi-bridge-js"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
pkgs.nodejs
|
||||
pkgs.typescript
|
||||
];
|
||||
src = lib.fileset.toSource {
|
||||
root = ../../komorebi-linux/src/kwin;
|
||||
fileset = lib.fileset.fileFilter (file: !file.hasExt "rs") ../../komorebi-linux/src/kwin;
|
||||
};
|
||||
}
|
||||
''
|
||||
cd $src
|
||||
tsc -p tsconfig.json
|
||||
node --test bridge.test.js
|
||||
touch $out
|
||||
'';
|
||||
|
||||
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-linux` write them
|
||||
linux-schema-fresh =
|
||||
pkgs.runCommand "komorebi-schema-fresh"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
build.komorebicForChecks
|
||||
pkgs.diffutils
|
||||
];
|
||||
}
|
||||
''
|
||||
komorebic static-config-schema | diff -u ${lib'.repoFile "schemas/linux/schema.json"} - \
|
||||
|| { echo "schemas/linux/schema.json is stale: run just jsonschema"; exit 1; }
|
||||
komorebic application-specific-configuration-schema | diff -u ${lib'.repoFile "schemas/linux/schema.asc.json"} - \
|
||||
|| { echo "schemas/linux/schema.asc.json is stale: run just jsonschema"; exit 1; }
|
||||
expected=$(sha256sum ${lib'.repoFile "schemas/linux/schema.json"} | cut -d' ' -f1)
|
||||
head -n 1 ${./komorebi-options.nix} | grep -qx "# schema-sha256: $expected" \
|
||||
|| { echo "nix/linux/komorebi-options.nix is stale: run just nixgen-linux"; exit 1; }
|
||||
touch $out
|
||||
'';
|
||||
|
||||
# the options the module is typed with, evaluated against the example configuration
|
||||
linux-nix-options-validation = import ./tests/default.nix { inherit pkgs; };
|
||||
|
||||
# every file of the key binding corpus through `komorebic hotkeys compile`, as the
|
||||
# module runs it
|
||||
linux-keybindings-fixtures = import ./tests/keybindings.nix {
|
||||
inherit pkgs;
|
||||
komorebic = build.fullBuild;
|
||||
};
|
||||
|
||||
# The NixOS module in real NixOS systems, evaluated and never built, so a Mac checks it
|
||||
# too. A VM suite, `vm-module`, runs it.
|
||||
linux-nixos-module-eval = import ./tests/nixos-module.nix {
|
||||
inherit pkgs;
|
||||
inherit (nixpkgs.lib) nixosSystem;
|
||||
module = self.nixosModules.default;
|
||||
komorebiFor = guestSystem: self.packages.${guestSystem}.komorebi-full;
|
||||
borderEffectFor = guestSystem: self.packages.${guestSystem}.kde-rounded-corners-komorebi;
|
||||
animationEffectFor = guestSystem: self.packages.${guestSystem}.kwin-effect-geometry-change-komorebi;
|
||||
};
|
||||
|
||||
# The Plasma guests to develop against, evaluated and never built, so that every system
|
||||
# sees an option that nixpkgs renamed or an assertion that fails. The QEMU guests are
|
||||
# systems in a VM (`vmVariant`), with a runner for the machine that runs QEMU; UTM's is
|
||||
# a system of its own. Each guest is for one kind of machine, which is also checked: the
|
||||
# architecture of the guest, the machine that runs its QEMU, and that a guest of a Linux
|
||||
# machine has KVM and one display device only.
|
||||
linux-plasma-guests-eval =
|
||||
let
|
||||
guests = self.nixosConfigurations;
|
||||
machines =
|
||||
let
|
||||
mac = {
|
||||
guest = "aarch64-linux";
|
||||
host = "aarch64-darwin";
|
||||
};
|
||||
linux = system: {
|
||||
guest = system;
|
||||
host = system;
|
||||
};
|
||||
# the runner of the demo is given its display device, its ports and whether to
|
||||
# insist on KVM when it starts, by `run-kde`
|
||||
demo = machine: machine // { demo = true; };
|
||||
in
|
||||
{
|
||||
plasma-vm = mac;
|
||||
plasma-vm-session = mac;
|
||||
plasma-vm-x86_64 = linux "x86_64-linux";
|
||||
plasma-vm-session-x86_64 = linux "x86_64-linux";
|
||||
plasma-vm-aarch64 = linux "aarch64-linux";
|
||||
plasma-vm-session-aarch64 = linux "aarch64-linux";
|
||||
run-kde-x86_64 = demo (linux "x86_64-linux");
|
||||
run-kde-aarch64 = demo (linux "aarch64-linux");
|
||||
};
|
||||
isDisplay =
|
||||
option: lib.hasPrefix "-device virtio-vga" option || lib.hasPrefix "-device virtio-gpu" option;
|
||||
qemuGuest =
|
||||
name:
|
||||
let
|
||||
machine = machines.${name};
|
||||
demo = machine.demo or false;
|
||||
vm = guests.${name}.config.virtualisation.vmVariant.virtualisation;
|
||||
in
|
||||
assert lib.assertMsg (
|
||||
guests.${name}.pkgs.stdenv.hostPlatform.system == machine.guest
|
||||
) "${name} is not a ${machine.guest} guest";
|
||||
assert lib.assertMsg (
|
||||
vm.host.pkgs.stdenv.hostPlatform.system == machine.host
|
||||
) "${name} does not run on a ${machine.host} host";
|
||||
assert lib.assertMsg (
|
||||
vm.qemu.forceAccel != demo
|
||||
) "${name} would run without KVM or HVF, which is too slow to use";
|
||||
assert lib.assertMsg (
|
||||
builtins.length (builtins.filter isDisplay vm.qemu.options) == (if demo then 0 else 1)
|
||||
) "${name} does not have the display devices it should have";
|
||||
assert lib.assertMsg
|
||||
# an x86_64 machine has a VGA of its own, which would be a second display
|
||||
((machine.guest == "x86_64-linux" && !demo) == builtins.elem "-vga none" vm.qemu.options)
|
||||
"${name} has `-vga none` if and only if it is an x86_64 guest with a display device";
|
||||
assert lib.assertMsg (
|
||||
demo -> (vm.forwardPorts == [ ] && vm.sharedDirectories.run-kde.target == "/run/run-kde")
|
||||
) "${name} does not leave its ports and its shared directory to the runner's environment";
|
||||
{
|
||||
${name} = guests.${name}.config.virtualisation.vmVariant.system.build.toplevel;
|
||||
"${name}, its runner" = guests.${name}.config.system.build.vm;
|
||||
};
|
||||
builds = lib.foldl' (builds: name: builds // qemuGuest name) { } (lib.attrNames machines) // {
|
||||
plasma-utm = guests.plasma-utm.config.system.build.toplevel;
|
||||
};
|
||||
lines = lib.mapAttrsToList (
|
||||
name: drv: "${name}: ${builtins.unsafeDiscardStringContext drv.drvPath}"
|
||||
) builds;
|
||||
in
|
||||
pkgs.runCommand "plasma-guests-eval" { } ''
|
||||
${lib.concatMapStringsSep "\n" (line: "echo ${lib.escapeShellArg line}") lines}
|
||||
''
|
||||
RUSTFMT=rustfmt bash ${lib'.repoFile "tools/format-all"} --check --root ${build.real}
|
||||
touch $out
|
||||
'';
|
||||
}
|
||||
# The probe builds (shellcheck runs over the script and over the guest's init as it
|
||||
# does) and its dry run works without a machine to probe, so that it cannot rot between
|
||||
# the times somebody runs it.
|
||||
// lib.optionalAttrs isLinux {
|
||||
linux-wsl2-probe = wsl2ProbeForChecks.probe;
|
||||
linux-wsl2-probe-dry-run =
|
||||
pkgs.runCommand "wsl2-probe-dry-run" { nativeBuildInputs = [ wsl2ProbeForChecks.probe ]; }
|
||||
''
|
||||
wsl2-probe --dry-run --no-prompt --report report.txt > out.txt
|
||||
cat out.txt
|
||||
for probe in P0 P1 P2 P3 P4 P5 P6; do
|
||||
grep -q "^$probe " out.txt || { echo "no verdict line for $probe"; exit 1; }
|
||||
done
|
||||
grep -q "PASTE THIS" out.txt
|
||||
grep -q "would run" out.txt
|
||||
# the report file has what the screen has
|
||||
grep -q "PASTE THIS" report.txt
|
||||
# a mistake in the options is refused
|
||||
if wsl2-probe --nonsense 2> err.txt; then exit 1; fi
|
||||
grep -q "unknown option" err.txt
|
||||
touch $out
|
||||
'';
|
||||
}
|
||||
# `run-kde` is shellchecked when it is built, and its output is what a test says it is
|
||||
// lib.optionalAttrs isLinux (
|
||||
lib.mapAttrs' (name: lib.nameValuePair "linux-${name}") (
|
||||
{
|
||||
run-kde = config.packages.run-kde;
|
||||
}
|
||||
// import ./tests/run-kde.nix {
|
||||
inherit pkgs;
|
||||
runKde = config.packages.run-kde;
|
||||
}
|
||||
)
|
||||
)
|
||||
# The VM tests need QEMU with KVM, so only Linux checks them. A Mac runs the same tests
|
||||
# through legacyPackages.<system>.vm, see docs/linux/dev/vm-tests.md.
|
||||
// lib.optionalAttrs isLinux (
|
||||
lib.mapAttrs' (name: test: lib.nameValuePair "vm-${name}" test) vm.suites
|
||||
)
|
||||
# the KWin effects komorebi drives, installed and inspected without a session
|
||||
// lib.optionalAttrs isLinux (
|
||||
lib.mapAttrs' (name: lib.nameValuePair "linux-${name}") (
|
||||
import ./tests/effects.nix {
|
||||
inherit pkgs;
|
||||
inherit (config) packages;
|
||||
}
|
||||
)
|
||||
|
||||
linux-clippy = build.craneLib.cargoClippy (
|
||||
build.individualCrateArgs
|
||||
// {
|
||||
cargoClippyExtraArgs = "--all-targets -- -D warnings";
|
||||
}
|
||||
);
|
||||
|
||||
legacyPackages = lib.optionalAttrs checkSystem (
|
||||
{
|
||||
# every suite, as a test with a `driver`, on every system
|
||||
vm = vm.suites;
|
||||
# the suites of each tier, for the CI matrix
|
||||
vmTiers = vm.tiers;
|
||||
# the guests of every suite, to build on a Linux builder when the host is a Mac
|
||||
vmGuests = vm.guests;
|
||||
}
|
||||
// lib.optionalAttrs isLinux {
|
||||
# the same suites on a machine with no KVM, which is slow but works anywhere
|
||||
vmTcg =
|
||||
(import ./tests/vm {
|
||||
hostPkgs = pkgs;
|
||||
inherit komorebiModule;
|
||||
scale = 8;
|
||||
}).suites;
|
||||
linux-doc = build.craneLib.cargoDoc (
|
||||
build.individualCrateArgs
|
||||
// {
|
||||
cargoDocExtraArgs = "--no-deps";
|
||||
env.RUSTDOCFLAGS = "-D warnings";
|
||||
}
|
||||
);
|
||||
|
||||
linux-toml-fmt = build.craneLib.taploFmt (
|
||||
build.workspaceArgs
|
||||
// {
|
||||
src = lib.sources.sourceFilesBySuffices build.real [ ".toml" ];
|
||||
}
|
||||
);
|
||||
|
||||
# cargo deny sees every member of the workspace: leave out the other platforms' packages (stubs
|
||||
# here); the policy is the one deny.toml of the repository
|
||||
linux-deny = build.craneLib.cargoDeny (
|
||||
build.workspaceArgs
|
||||
// {
|
||||
inherit (build) src;
|
||||
cargoDenyExtraArgs =
|
||||
"--workspace " + lib.concatMapStringsSep " " (p: "--exclude ${p}") build.stubbedPackages;
|
||||
cargoDenyChecks = "bans licenses sources";
|
||||
}
|
||||
);
|
||||
|
||||
linux-nextest = build.craneLib.cargoNextest (build.individualCrateArgs // { doCheck = true; });
|
||||
|
||||
# The bridge is not Rust: tsc checks its types from its JSDoc comments, and node runs
|
||||
# its tests against a fake KWin. No package.json and no build step.
|
||||
linux-bridge-js =
|
||||
pkgs.runCommand "komorebi-bridge-js"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
pkgs.nodejs
|
||||
pkgs.typescript
|
||||
];
|
||||
src = lib.fileset.toSource {
|
||||
root = ../../komorebi-linux/src/kwin;
|
||||
fileset = lib.fileset.fileFilter (file: !file.hasExt "rs") ../../komorebi-linux/src/kwin;
|
||||
};
|
||||
}
|
||||
''
|
||||
cd $src
|
||||
tsc -p tsconfig.json
|
||||
node --test bridge.test.js
|
||||
touch $out
|
||||
'';
|
||||
|
||||
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-linux` write them
|
||||
linux-schema-fresh =
|
||||
pkgs.runCommand "komorebi-schema-fresh"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
build.komorebicForChecks
|
||||
pkgs.diffutils
|
||||
];
|
||||
}
|
||||
''
|
||||
komorebic static-config-schema | diff -u ${lib'.repoFile "schemas/linux/schema.json"} - \
|
||||
|| { echo "schemas/linux/schema.json is stale: run just jsonschema"; exit 1; }
|
||||
komorebic application-specific-configuration-schema | diff -u ${lib'.repoFile "schemas/linux/schema.asc.json"} - \
|
||||
|| { echo "schemas/linux/schema.asc.json is stale: run just jsonschema"; exit 1; }
|
||||
expected=$(sha256sum ${lib'.repoFile "schemas/linux/schema.json"} | cut -d' ' -f1)
|
||||
head -n 1 ${./komorebi-options.nix} | grep -qx "# schema-sha256: $expected" \
|
||||
|| { echo "nix/linux/komorebi-options.nix is stale: run just nixgen-linux"; exit 1; }
|
||||
touch $out
|
||||
'';
|
||||
|
||||
# the options the module is typed with, evaluated against the example configuration
|
||||
linux-nix-options-validation = import ./tests/default.nix { inherit pkgs; };
|
||||
|
||||
# every file of the key binding corpus through `komorebic hotkeys compile`, as the
|
||||
# module runs it
|
||||
linux-keybindings-fixtures = import ./tests/keybindings.nix {
|
||||
inherit pkgs;
|
||||
komorebic = build.fullBuild;
|
||||
};
|
||||
|
||||
# The NixOS module in real NixOS systems, evaluated and never built, so a Mac checks it
|
||||
# too. A VM suite, `vm-module`, runs it.
|
||||
linux-nixos-module-eval = import ./tests/nixos-module.nix {
|
||||
inherit pkgs;
|
||||
inherit (nixpkgs.lib) nixosSystem;
|
||||
module = self.nixosModules.default;
|
||||
komorebiFor = guestSystem: self.packages.${guestSystem}.komorebi-full;
|
||||
borderEffectFor = guestSystem: self.packages.${guestSystem}.kde-rounded-corners-komorebi;
|
||||
animationEffectFor = guestSystem: self.packages.${guestSystem}.kwin-effect-geometry-change-komorebi;
|
||||
};
|
||||
|
||||
# The Plasma guests to develop against, evaluated and never built, so that every system
|
||||
# sees an option that nixpkgs renamed or an assertion that fails. The QEMU guests are
|
||||
# systems in a VM (`vmVariant`), with a runner for the machine that runs QEMU; UTM's is
|
||||
# a system of its own. Each guest is for one kind of machine, which is also checked: the
|
||||
# architecture of the guest, the machine that runs its QEMU, and that a guest of a Linux
|
||||
# machine has KVM and one display device only.
|
||||
linux-plasma-guests-eval =
|
||||
let
|
||||
guests = self.nixosConfigurations;
|
||||
machines =
|
||||
let
|
||||
mac = {
|
||||
guest = "aarch64-linux";
|
||||
host = "aarch64-darwin";
|
||||
};
|
||||
linux = system: {
|
||||
guest = system;
|
||||
host = system;
|
||||
};
|
||||
# the runner of the demo is given its display device, its ports and whether to
|
||||
# insist on KVM when it starts, by `run-kde`
|
||||
demo = machine: machine // { demo = true; };
|
||||
in
|
||||
{
|
||||
plasma-vm = mac;
|
||||
plasma-vm-session = mac;
|
||||
plasma-vm-x86_64 = linux "x86_64-linux";
|
||||
plasma-vm-session-x86_64 = linux "x86_64-linux";
|
||||
plasma-vm-aarch64 = linux "aarch64-linux";
|
||||
plasma-vm-session-aarch64 = linux "aarch64-linux";
|
||||
run-kde-x86_64 = demo (linux "x86_64-linux");
|
||||
run-kde-aarch64 = demo (linux "aarch64-linux");
|
||||
};
|
||||
isDisplay =
|
||||
option: lib.hasPrefix "-device virtio-vga" option || lib.hasPrefix "-device virtio-gpu" option;
|
||||
qemuGuest =
|
||||
name:
|
||||
let
|
||||
machine = machines.${name};
|
||||
demo = machine.demo or false;
|
||||
vm = guests.${name}.config.virtualisation.vmVariant.virtualisation;
|
||||
in
|
||||
assert lib.assertMsg (
|
||||
guests.${name}.pkgs.stdenv.hostPlatform.system == machine.guest
|
||||
) "${name} is not a ${machine.guest} guest";
|
||||
assert lib.assertMsg (
|
||||
vm.host.pkgs.stdenv.hostPlatform.system == machine.host
|
||||
) "${name} does not run on a ${machine.host} host";
|
||||
assert lib.assertMsg (
|
||||
vm.qemu.forceAccel != demo
|
||||
) "${name} would run without KVM or HVF, which is too slow to use";
|
||||
assert lib.assertMsg (
|
||||
builtins.length (builtins.filter isDisplay vm.qemu.options) == (if demo then 0 else 1)
|
||||
) "${name} does not have the display devices it should have";
|
||||
assert lib.assertMsg
|
||||
# an x86_64 machine has a VGA of its own, which would be a second display
|
||||
((machine.guest == "x86_64-linux" && !demo) == builtins.elem "-vga none" vm.qemu.options)
|
||||
"${name} has `-vga none` if and only if it is an x86_64 guest with a display device";
|
||||
assert lib.assertMsg (
|
||||
demo -> (vm.forwardPorts == [ ] && vm.sharedDirectories.run-kde.target == "/run/run-kde")
|
||||
) "${name} does not leave its ports and its shared directory to the runner's environment";
|
||||
{
|
||||
${name} = guests.${name}.config.virtualisation.vmVariant.system.build.toplevel;
|
||||
"${name}, its runner" = guests.${name}.config.system.build.vm;
|
||||
};
|
||||
builds = lib.foldl' (builds: name: builds // qemuGuest name) { } (lib.attrNames machines) // {
|
||||
plasma-utm = guests.plasma-utm.config.system.build.toplevel;
|
||||
};
|
||||
lines = lib.mapAttrsToList (
|
||||
name: drv: "${name}: ${builtins.unsafeDiscardStringContext drv.drvPath}"
|
||||
) builds;
|
||||
in
|
||||
pkgs.runCommand "plasma-guests-eval" { } ''
|
||||
${lib.concatMapStringsSep "\n" (line: "echo ${lib.escapeShellArg line}") lines}
|
||||
touch $out
|
||||
'';
|
||||
}
|
||||
)
|
||||
# The probe builds (shellcheck runs over the script and over the guest's init as it
|
||||
# does) and its dry run works without a machine to probe, so that it cannot rot between
|
||||
# the times somebody runs it.
|
||||
// lib.optionalAttrs isLinux {
|
||||
linux-wsl2-probe = wsl2ProbeForChecks.probe;
|
||||
linux-wsl2-probe-dry-run =
|
||||
pkgs.runCommand "wsl2-probe-dry-run" { nativeBuildInputs = [ wsl2ProbeForChecks.probe ]; }
|
||||
''
|
||||
wsl2-probe --dry-run --no-prompt --report report.txt > out.txt
|
||||
cat out.txt
|
||||
for probe in P0 P1 P2 P3 P4 P5 P6; do
|
||||
grep -q "^$probe " out.txt || { echo "no verdict line for $probe"; exit 1; }
|
||||
done
|
||||
grep -q "PASTE THIS" out.txt
|
||||
grep -q "would run" out.txt
|
||||
# the report file has what the screen has
|
||||
grep -q "PASTE THIS" report.txt
|
||||
# a mistake in the options is refused
|
||||
if wsl2-probe --nonsense 2> err.txt; then exit 1; fi
|
||||
grep -q "unknown option" err.txt
|
||||
touch $out
|
||||
'';
|
||||
}
|
||||
# `run-kde` is shellchecked when it is built, and its output is what a test says it is
|
||||
// lib.optionalAttrs isLinux (
|
||||
lib.mapAttrs' (name: lib.nameValuePair "linux-${name}") (
|
||||
{
|
||||
run-kde = config.packages.run-kde;
|
||||
}
|
||||
// import ./tests/run-kde.nix {
|
||||
inherit pkgs;
|
||||
runKde = config.packages.run-kde;
|
||||
}
|
||||
)
|
||||
)
|
||||
# The VM tests need QEMU with KVM, so only Linux checks them. A Mac runs the same tests
|
||||
# through legacyPackages.<system>.vm, see docs/linux/dev/vm-tests.md.
|
||||
// lib.optionalAttrs isLinux (
|
||||
lib.mapAttrs' (name: test: lib.nameValuePair "vm-${name}" test) vm.suites
|
||||
)
|
||||
# the KWin effects komorebi drives, installed and inspected without a session
|
||||
// lib.optionalAttrs isLinux (
|
||||
lib.mapAttrs' (name: lib.nameValuePair "linux-${name}") (
|
||||
import ./tests/effects.nix {
|
||||
inherit pkgs;
|
||||
inherit (config) packages;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
legacyPackages = lib.optionalAttrs checkSystem (
|
||||
{
|
||||
# every suite, as a test with a `driver`, on every system
|
||||
vm = vm.suites;
|
||||
# the suites of each tier, for the CI matrix
|
||||
vmTiers = vm.tiers;
|
||||
# the guests of every suite, to build on a Linux builder when the host is a Mac
|
||||
vmGuests = vm.guests;
|
||||
}
|
||||
// lib.optionalAttrs isLinux {
|
||||
# the same suites on a machine with no KVM, which is slow but works anywhere
|
||||
vmTcg =
|
||||
(import ./tests/vm {
|
||||
hostPkgs = pkgs;
|
||||
inherit komorebiModule;
|
||||
scale = 8;
|
||||
}).suites;
|
||||
}
|
||||
);
|
||||
}
|
||||
// lib.optionalAttrs (builtins.elem system lib'.linuxSystems) {
|
||||
packages = {
|
||||
inherit (build) komorebi komorebic;
|
||||
|
||||
@@ -21,7 +21,7 @@ in
|
||||
nightlyRustfmt = pkgs.rust-bin.nightly.latest.rustfmt;
|
||||
in
|
||||
lib.optionalAttrs (builtins.elem system lib'.macosSystems) {
|
||||
checks = {
|
||||
allChecks = {
|
||||
macos-clippy = build.craneLib.cargoClippy build.individualCrateArgs;
|
||||
|
||||
# the nightly rustfmt over the macOS files only (the source of this platform has no others), with
|
||||
|
||||
@@ -73,7 +73,7 @@ in
|
||||
};
|
||||
}
|
||||
// lib.optionalAttrs (builtins.elem system lib'.windowsSystems) {
|
||||
checks = {
|
||||
allChecks = {
|
||||
windows-clippy = build.craneLib.cargoClippy (
|
||||
build.individualCrateArgs
|
||||
// {
|
||||
|
||||
Reference in new issue
Block a user