mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-12-01 04:34:11 +01:00
The daemon takes its settings from a komorebi.json: the file --config names, or the one in the config home ($KOMOREBI_CONFIG_HOME, else ~/.config/komorebi). Without a file it runs on its defaults, as before. StaticConfig reads the file in three steps, because the monitors are known only after the backend has been asked. preload makes the window manager and applies the settings that are process-wide, postload gives each monitor and workspace the entry of its place (by the index display_index_preferences gives a monitor's serial number id, else in order), and main asks KWin for a desktop for each workspace the file lists. A watcher on the file sends the daemon a ReloadStaticConfiguration about two seconds after it changes, whether an editor wrote the file in place or renamed a new one over it, and a file that does not parse changes nothing. A workspace can change its layout, its work area offset and its layout options with the number of its containers, from the file or with komorebic (workspace-layout-rule, its named form and the two that clear), and layout_defaults gives every workspace of a layout the options it sets none of. One file is meant to serve every platform, so a key that does nothing on Plasma is accepted and ignored. config_parity checks the example and the files of other platforms; the keys of features that are not in yet are listed there, and the test fails when a list names a key that is read. The file also sets what the stacks, the float override, the floating layer and monocle set while the daemon runs: window_container_behaviour, with its rules by container count in a workspace, float_override, float_override_placement, floating_layer_behaviour (for a monitor and a workspace too), floating_layer_placement and monocle_focus_behaviour. Their features come before this commit, but a file to put the keys in does not, so they are part of this one. komorebic gains configuration, generate-static-config and start --config. The NixOS module gets configFile, which the unit gives the daemon as --config.
240 lines
7.3 KiB
Nix
240 lines
7.3 KiB
Nix
# `nixos-module-eval`: `services.komorebi` in real NixOS systems, evaluated and never built. Each
|
|
# scenario is a `nixosSystem` with the module, and the checks read what it evaluates to: the
|
|
# assertions, the unit the module defines, and its read-only `execStart`. A scenario that must
|
|
# not evaluate is caught with `builtins.tryEval`. Nothing here builds a Linux package (the
|
|
# derivation below gets only check names and booleans), so a Mac runs it too.
|
|
{
|
|
pkgs,
|
|
# nixpkgs' `lib.nixosSystem`
|
|
nixosSystem,
|
|
# the module, as the flake exports it, with its overlay
|
|
module,
|
|
# the flake's komorebi-full for a system, which the overlay has to provide
|
|
komorebiFor,
|
|
}:
|
|
let
|
|
inherit (pkgs) lib;
|
|
|
|
# the systems are of the host's architecture
|
|
system = "${pkgs.stdenv.hostPlatform.parsed.cpu.name}-linux";
|
|
|
|
# enough of a machine for every NixOS assertion to hold, since no scenario is ever built
|
|
machine = {
|
|
nixpkgs.hostPlatform = system;
|
|
boot.loader.grub.enable = false;
|
|
fileSystems."/" = {
|
|
device = "/dev/vda";
|
|
fsType = "ext4";
|
|
};
|
|
system.stateVersion = lib.trivial.release;
|
|
};
|
|
|
|
plasma = {
|
|
services.desktopManager.plasma6.enable = true;
|
|
};
|
|
|
|
eval =
|
|
scenario:
|
|
(nixosSystem {
|
|
modules = [
|
|
module
|
|
machine
|
|
scenario
|
|
];
|
|
}).config;
|
|
|
|
enabled = eval {
|
|
imports = [ plasma ];
|
|
services.komorebi.enable = true;
|
|
};
|
|
|
|
disabled = eval plasma;
|
|
|
|
withoutPlasma = eval { services.komorebi.enable = true; };
|
|
|
|
debug = eval {
|
|
imports = [ plasma ];
|
|
services.komorebi = {
|
|
enable = true;
|
|
logLevel = "debug";
|
|
};
|
|
};
|
|
|
|
# a package that is not the overlay's: any package will do, since nothing is built
|
|
otherPackage = eval (
|
|
{ pkgs, ... }:
|
|
{
|
|
imports = [ plasma ];
|
|
services.komorebi = {
|
|
enable = true;
|
|
package = pkgs.hello;
|
|
};
|
|
}
|
|
);
|
|
|
|
withConfigFile = eval (
|
|
{ pkgs, ... }:
|
|
{
|
|
imports = [ plasma ];
|
|
services.komorebi = {
|
|
enable = true;
|
|
configFile = pkgs.writeText "komorebi.json" "{}";
|
|
};
|
|
}
|
|
);
|
|
|
|
unknownLevel = eval {
|
|
imports = [ plasma ];
|
|
services.komorebi = {
|
|
enable = true;
|
|
logLevel = "verbose";
|
|
};
|
|
};
|
|
|
|
execStartSet = eval {
|
|
imports = [ plasma ];
|
|
services.komorebi = {
|
|
enable = true;
|
|
execStart = "/bin/true";
|
|
};
|
|
};
|
|
|
|
failed = config: map (a: a.message) (lib.filter (a: !a.assertion) config.assertions);
|
|
unit = config: config.systemd.user.services.komorebi;
|
|
evaluates = value: (builtins.tryEval value).success;
|
|
|
|
checks = [
|
|
{
|
|
name = "enabled with Plasma 6, every assertion holds";
|
|
ok = failed enabled == [ ];
|
|
got = failed enabled;
|
|
}
|
|
{
|
|
name = "the unit is started by plasma-workspace.target";
|
|
ok = (unit enabled).wantedBy == [ "plasma-workspace.target" ];
|
|
got = (unit enabled).wantedBy;
|
|
}
|
|
{
|
|
name = "the unit starts after plasma-core.target";
|
|
ok = lib.elem "plasma-core.target" (unit enabled).after;
|
|
got = (unit enabled).after;
|
|
}
|
|
{
|
|
name = "the unit is restarted when it fails";
|
|
ok = (unit enabled).serviceConfig.Restart == "on-failure";
|
|
}
|
|
{
|
|
name = "the unit counts the exit status of a SIGTERM (130) as success";
|
|
ok = (unit enabled).serviceConfig.SuccessExitStatus == 130;
|
|
}
|
|
{
|
|
name = "the unit runs execStart";
|
|
ok = (unit enabled).serviceConfig.ExecStart == enabled.services.komorebi.execStart;
|
|
got = (unit enabled).serviceConfig.ExecStart;
|
|
}
|
|
{
|
|
name = "execStart is bin/komorebi of the package, at the info level";
|
|
ok =
|
|
enabled.services.komorebi.execStart
|
|
== "${enabled.services.komorebi.package}/bin/komorebi --log-level info";
|
|
got = enabled.services.komorebi.execStart;
|
|
}
|
|
{
|
|
name = "the default package is the flake's komorebi-full, from the overlay";
|
|
ok = enabled.services.komorebi.package.outPath == (komorebiFor system).outPath;
|
|
}
|
|
{
|
|
name = "the unit has the PATH of the user's session";
|
|
ok =
|
|
(unit enabled).environment.PATH
|
|
== "/run/wrappers/bin:/etc/profiles/per-user/%u/bin:/run/current-system/sw/bin";
|
|
got = (unit enabled).environment.PATH;
|
|
}
|
|
{
|
|
name = "the package is installed in the system profile";
|
|
ok = lib.elem enabled.services.komorebi.package enabled.environment.systemPackages;
|
|
}
|
|
{
|
|
name = "disabled, every assertion holds";
|
|
ok = failed disabled == [ ];
|
|
got = failed disabled;
|
|
}
|
|
{
|
|
name = "disabled, there is no unit";
|
|
ok = !(disabled.systemd.user.services ? komorebi);
|
|
}
|
|
{
|
|
name = "disabled, nothing is installed";
|
|
ok = !(lib.elem disabled.services.komorebi.package disabled.environment.systemPackages);
|
|
}
|
|
{
|
|
name = "without Plasma 6, an assertion fails and names the option to set";
|
|
ok = lib.any (lib.hasInfix "services.desktopManager.plasma6.enable = true") (failed withoutPlasma);
|
|
got = failed withoutPlasma;
|
|
}
|
|
{
|
|
name = "logLevel reaches execStart and the unit";
|
|
ok =
|
|
debug.services.komorebi.execStart
|
|
== "${debug.services.komorebi.package}/bin/komorebi --log-level debug"
|
|
&& (unit debug).serviceConfig.ExecStart == debug.services.komorebi.execStart;
|
|
got = (unit debug).serviceConfig.ExecStart;
|
|
}
|
|
{
|
|
name = "another package is the one the unit runs and the one installed";
|
|
ok =
|
|
(unit otherPackage).serviceConfig.ExecStart
|
|
== "${otherPackage.services.komorebi.package}/bin/komorebi --log-level info"
|
|
&& lib.elem otherPackage.services.komorebi.package otherPackage.environment.systemPackages;
|
|
got = (unit otherPackage).serviceConfig.ExecStart;
|
|
}
|
|
{
|
|
name = "without a configFile, the unit passes no --config";
|
|
ok = !(lib.hasInfix "--config" enabled.services.komorebi.execStart);
|
|
got = enabled.services.komorebi.execStart;
|
|
}
|
|
{
|
|
name = "configFile reaches execStart and the unit as --config, after the log level";
|
|
ok =
|
|
withConfigFile.services.komorebi.execStart
|
|
== "${withConfigFile.services.komorebi.package}/bin/komorebi --log-level info --config ${withConfigFile.services.komorebi.configFile}"
|
|
&& (unit withConfigFile).serviceConfig.ExecStart == withConfigFile.services.komorebi.execStart;
|
|
got = (unit withConfigFile).serviceConfig.ExecStart;
|
|
}
|
|
{
|
|
name = "a log level the daemon does not have does not evaluate";
|
|
ok = !(evaluates unknownLevel.services.komorebi.logLevel);
|
|
}
|
|
{
|
|
name = "execStart cannot be set";
|
|
ok = !(evaluates execStartSet.services.komorebi.execStart);
|
|
}
|
|
];
|
|
|
|
failures = lib.filter (check: !check.ok) checks;
|
|
|
|
# what a failed check got, without the store paths' context: this derivation must not depend on
|
|
# a Linux package
|
|
show =
|
|
check:
|
|
check.name
|
|
+ lib.optionalString (check ? got) (
|
|
": got " + builtins.unsafeDiscardStringContext (builtins.toJSON check.got)
|
|
);
|
|
in
|
|
pkgs.runCommand "nixos-module-eval" { } (
|
|
if failures == [ ] then
|
|
''
|
|
${lib.concatMapStringsSep "\n" (check: "echo ${lib.escapeShellArg "ok: ${check.name}"}") checks}
|
|
echo "${toString (lib.length checks)} checks of services.komorebi passed"
|
|
touch $out
|
|
''
|
|
else
|
|
''
|
|
${lib.concatMapStringsSep "\n" (
|
|
check: "echo ${lib.escapeShellArg "FAILED: ${show check}"}"
|
|
) failures}
|
|
exit 1
|
|
''
|
|
)
|