build(nix): build the KDE and macOS packages from the root workspace

The three flakes now build from the one root Cargo workspace (previous revision, which must land with
this one). nix/workspace-src.nix assembles each platform's source: the files it needs (its crates, the
root crates they depend on, the root Cargo.toml and Cargo.lock) plus a stub (the member's own
manifest, an empty lib.rs, a main that does nothing) for every other member, because cargo has to load
the whole workspace but must not depend on the other platforms' code. The KDE and macOS flakes pass
-p <their packages> (cargoExtraArgs), no longer cd into a subdirectory workspace, use the root
Cargo.lock/Cargo.toml (vendored from the filtered source, so crane does not read the stubbed one),
and run cargo deny with --workspace --exclude <the other platforms' packages> and their own
deny.toml; the root flake excludes the KDE and macOS packages from deny and builds default-members.
komorebic/applications.json is added to the macOS source filter (it is embedded by include_str!).
The KDE/macOS deny.toml clarify entries and root deny.toml follow the package renames (squashed into
the rename revisions).

Evaluation (nix eval drvPath, no build): Windows clippy, deny, fmt, nextest, toml-fmt; kfde clippy,
doc, deny, fmt, toml-fmt, nextest, schema-fresh; kfde-komorebi, kfde-komorebic, komorebic. Cache
isolation measured by evaluation: an edit of crates/komorebi-bar-core or komorebi/src changes the
Windows drvs and leaves the kfde clippy and nextest drvs unchanged; an edit of komorebi-for-kde changes
kfde and leaves Windows unchanged; an edit of komorebi-for-mac changes neither. tools/kde-closure-check
ok (rewritten for the merged workspace), root-crates.json unchanged.

KNOWN LIMITS: (1) the stubbed source is a derivation that crane reads at evaluation (readDir in
mkDummySrc), so evaluating or building another system's attributes needs a builder for that system:
`nix flake show --all-systems` and drvPath of aarch64-darwin attributes now fail on a Linux host (the
fast-check nix step evaluates the current system only). (2) cargo deny, fmt and taplo behaviour in the
merged workspace is unverified: not built. (3) the version placeholder warning of crane for the
virtual root manifest (cosmetic).

Needs from the coordinator (idle host, heavy gates): nix build -L .#checks.x86_64-linux.komorebi-workspace-clippy
(the root deps derivation is a new one because of the lock), .#checks.x86_64-linux.komorebi-workspace-deny,
-fmt, -nextest, -toml-fmt; the same for kfde-komorebi-workspace-{clippy,deny,fmt,nextest,toml-fmt,doc},
kfde-schema-fresh, .#packages.x86_64-linux.kfde-komorebic and kfde-komorebi; then one KDE VM fast run
(the KDE package derivation changed); on a Mac or a darwin builder: .#packages.aarch64-darwin.kfm-komorebic,
kfm-komorebi, kfm-komorebi-bar and the kfm checks. Not run by me: any of these.
This commit is contained in:
LGUG2Z committed 2026-10-31 12:06:27 -07:00
1 parent 03072f4fdb
commit 80a749b37e
4 files changed
+178 -26

No files matched your search

+41 -5
View File
@@ -215,11 +215,13 @@
msvcEnv = mkMsvcEnv { inherit pkgs windowsSdk; };
src = pkgs.lib.cleanSourceWith {
# the files of the Windows crates; the KDE and macOS crates are in the same Cargo workspace and
# are added as stubs (nix/workspace-src.nix), so that an edit of one changes nothing here
real = pkgs.lib.cleanSourceWith {
src = ./.;
filter =
path: type:
# the other platforms' trees have their own workspaces and are built by their own outputs
# the other platforms' crates are added as stubs below
!(pkgs.lib.hasInfix "/komorebi-for-kde" path || pkgs.lib.hasInfix "/komorebi-for-mac" path)
&& (
(craneLib.filterCargoSources path type)
@@ -229,11 +231,21 @@
);
};
src = import ./nix/workspace-src.nix {
inherit pkgs real;
repoRoot = ./.;
isReal = member: !(pkgs.lib.hasPrefix "komorebi-for-" member);
};
commonArgs = {
inherit src version;
cargoLock = "${real}/Cargo.lock";
cargoToml = "${real}/Cargo.toml";
# vendored from the filtered source, not the stubbed one: no build is needed to evaluate
cargoVendorDir = craneLib.vendorCargoDeps { src = real; };
strictDeps = true;
# komorebic/build.rs downloads applications.json if it is missing, which
# is not possible in the sandbox, so provide the pinned copy instead
# applications.json is committed now; this copies the pinned asc input over it, so that the
# embedded file is the pinned one even when the committed copy is older
preBuild = "mkdir -p komorebic && cp ${inputs.asc}/applications.json komorebic/applications.json";
# a constant, so that the dependencies and every check are the same
# derivations for every commit; only fullBuild stamps the real one
@@ -299,6 +311,7 @@
inherit
craneLib
src
real
individualCrateArgs
fullBuild
msvcEnv
@@ -496,14 +509,37 @@
komorebi-workspace-fmt = build.craneLib.cargoFmt {
inherit (build) src;
pname = "komorebi-workspace";
version = "0.1.0";
cargoToml = "${build.real}/Cargo.toml";
};
komorebi-workspace-toml-fmt = build.craneLib.taploFmt {
src = pkgs.lib.sources.sourceFilesBySuffices build.src [ ".toml" ];
src = pkgs.lib.sources.sourceFilesBySuffices build.real [ ".toml" ];
};
# cargo deny sees every member of the workspace: leave out the KDE and macOS packages, which
# have their own policy (komorebi-for-*/deny.toml) in their own checks
komorebi-workspace-deny = build.craneLib.cargoDeny {
inherit (build) src;
pname = "komorebi-workspace";
version = "0.1.0";
cargoToml = "${build.real}/Cargo.toml";
cargoLock = "${build.real}/Cargo.lock";
cargoDenyExtraArgs =
"--workspace "
+ pkgs.lib.concatMapStringsSep " " (p: "--exclude ${p}") [
"komorebi-linux"
"komorebic-linux"
"komorebi-client-linux"
"komorebi-hotkeys"
"version-linux"
"komorebi-macos"
"komorebic-macos"
"komorebi-client-macos"
"komorebi-bar-macos"
"version-macos"
];
};
komorebi-workspace-nextest = build.craneLib.cargoNextest build.individualCrateArgs;
+51 -12
View File
@@ -60,7 +60,7 @@
# the repository, cut down to this workspace and the crates of the root workspace it depends
# on by path (komorebi-layouts and what they depend on, komorebi-themes), with the root
# manifest those crates inherit their dependencies from
src = pkgs.lib.cleanSourceWith {
real = pkgs.lib.cleanSourceWith {
src = repoRoot;
filter =
path: type:
@@ -74,7 +74,7 @@
# the directory that holds the crates of crates/, to reach the listed ones
rootCrateParent = relative == "crates";
in
((rootCrate || rootCrateParent) && !(pkgs.lib.hasSuffix "/Cargo.lock" path) || relative == "Cargo.toml" || inTree)
((rootCrate || rootCrateParent) && !(pkgs.lib.hasSuffix "/Cargo.lock" path) || relative == "Cargo.toml" || relative == "Cargo.lock" || inTree)
&&
# the VM tests (their library, scripts and the states they keep) are not built, so
# editing one does not change the source the daemon is built from
@@ -98,17 +98,30 @@
);
};
# the workspace is in a subdirectory of the source, next to the crates it depends on
# the platform is a part of the one workspace of the repository: cargo loads every member (the
# others are stubs, see nix/workspace-src.nix) and is told which packages are this platform's
src = import (repoRoot + "/nix/workspace-src.nix") {
inherit pkgs repoRoot real;
isReal =
member:
pkgs.lib.hasPrefix "${platformDir}/" member
|| builtins.any (crate: member == crate || pkgs.lib.hasPrefix "${crate}/" member) rootCrates;
};
packages = "-p komorebi-linux -p komorebic-linux -p komorebi-client-linux -p komorebi-hotkeys";
workspaceArgs = {
cargoLock = "${src}/${platformDir}/Cargo.lock";
cargoToml = "${src}/${platformDir}/Cargo.toml";
postUnpack = "cd $sourceRoot/${platformDir}; sourceRoot=$PWD";
pname = "komorebi-workspace";
version = (builtins.fromTOML (builtins.readFile ./komorebi/Cargo.toml)).package.version;
cargoLock = "${real}/Cargo.lock";
cargoToml = "${real}/Cargo.toml";
# vendored from the filtered source, not the stubbed one: no build is needed to evaluate
cargoVendorDir = craneLib.vendorCargoDeps { src = real; };
};
commonArgs = workspaceArgs // {
cargoExtraArgs = "--locked ${packages}";
inherit src;
pname = "komorebi-workspace";
version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).workspace.package.version;
version = (builtins.fromTOML (builtins.readFile ./komorebi/Cargo.toml)).package.version;
strictDeps = true;
# The version crate wants a commit at compile time. It is a constant here, so that the
# dependencies and every check are the same derivations for every commit; only the final
@@ -148,7 +161,9 @@
craneLib
craneLibFmt
src
real
workspaceArgs
packages
commonArgs
individualCrateArgs
fullBuild
@@ -277,20 +292,20 @@
checks = {
komorebi-workspace-fmt = build.craneLibFmt.cargoFmt (
build.workspaceArgs // { inherit (build) src; }
build.workspaceArgs // { inherit (build) src; cargoExtraArgs = build.packages; }
);
komorebi-workspace-clippy = build.craneLib.cargoClippy (
build.individualCrateArgs
// {
cargoClippyExtraArgs = "--workspace --all-targets -- -D warnings";
cargoClippyExtraArgs = "--all-targets -- -D warnings";
}
);
komorebi-workspace-doc = build.craneLib.cargoDoc (
build.individualCrateArgs
// {
cargoDocExtraArgs = "--workspace --no-deps";
cargoDocExtraArgs = "--no-deps";
env.RUSTDOCFLAGS = "-D warnings";
}
);
@@ -298,12 +313,36 @@
komorebi-workspace-toml-fmt = build.craneLib.taploFmt (
build.workspaceArgs
// {
src = lib.sources.sourceFilesBySuffices build.src [ ".toml" ];
src = lib.sources.sourceFilesBySuffices build.real [ ".toml" ];
}
);
# cargo deny sees every member of the workspace: leave out the other platforms' packages
# and use this tree's policy
komorebi-workspace-deny = build.craneLib.cargoDeny (
build.workspaceArgs // { inherit (build) src; }
build.workspaceArgs
// {
inherit (build) src;
cargoDenyExtraArgs =
"--workspace "
+ lib.concatMapStringsSep " " (p: "--exclude ${p}") [
"komorebi-windows"
"komorebi-client"
"komorebi-gui"
"komorebic"
"komorebic-no-console"
"komorebi-bar"
"komorebi-shortcuts"
"komorebi-e2e-agent"
"komorebi-testwin"
"komorebi-macos"
"komorebic-macos"
"komorebi-client-macos"
"komorebi-bar-macos"
"version-macos"
];
cargoDenyChecks = "--config ${platformDir}/deny.toml bans licenses sources";
}
);
komorebi-workspace-nextest = build.craneLib.cargoNextest (
+50 -9
View File
@@ -51,7 +51,7 @@
# the repository, cut down to this workspace and the crates of the root workspace it depends
# on by path, with the root manifest those crates inherit their dependencies from
src = pkgs.lib.cleanSourceWith {
real = pkgs.lib.cleanSourceWith {
src = repoRoot;
filter =
path: type:
@@ -63,22 +63,37 @@
crate: relative == crate || pkgs.lib.hasPrefix "${crate}/" relative
) rootCrates;
in
(rootCrate && !(pkgs.lib.hasSuffix "/Cargo.lock" path) || relative == "Cargo.toml" || inTree)
(rootCrate && !(pkgs.lib.hasSuffix "/Cargo.lock" path) || relative == "Cargo.toml" || relative == "Cargo.lock" || inTree)
&& (
(craneLib.filterCargoSources path type)
|| (pkgs.lib.hasInfix "/docs/" path)
|| (builtins.match ".*/docs/.*" path != null)
# embedded by include_str! in komorebic
|| (pkgs.lib.hasSuffix "/komorebic/applications.json" path)
);
};
# the workspace is in a subdirectory of the source, next to the crates it depends on
# the platform is a part of the one workspace of the repository: cargo loads every member (the
# others are stubs, see nix/workspace-src.nix) and is told which packages are this platform's
src = import (repoRoot + "/nix/workspace-src.nix") {
inherit pkgs repoRoot real;
isReal =
member:
pkgs.lib.hasPrefix "${platformDir}/" member
|| builtins.any (crate: member == crate || pkgs.lib.hasPrefix "${crate}/" member) rootCrates;
};
packages = "-p komorebi-macos -p komorebic-macos -p komorebi-client-macos -p komorebi-bar-macos";
workspaceArgs = {
cargoLock = "${src}/${platformDir}/Cargo.lock";
cargoToml = "${src}/${platformDir}/Cargo.toml";
postUnpack = "cd $sourceRoot/${platformDir}; sourceRoot=$PWD";
pname = "komorebi-workspace";
inherit version;
cargoLock = "${real}/Cargo.lock";
cargoToml = "${real}/Cargo.toml";
# vendored from the filtered source, not the stubbed one: no build is needed to evaluate
cargoVendorDir = craneLib.vendorCargoDeps { src = real; };
};
commonArgs = workspaceArgs // {
cargoExtraArgs = "--locked ${packages}";
inherit src version;
strictDeps = true;
COMMIT_HASH = self.rev or (pkgs.lib.removeSuffix "-dirty" (self.dirtyRev or "unknown"));
@@ -127,7 +142,9 @@
inherit
craneLib
src
real
workspaceArgs
packages
individualCrateArgs
fullBuild
;
@@ -192,17 +209,41 @@
checks = {
komorebi-workspace-clippy = build.craneLib.cargoClippy build.individualCrateArgs;
komorebi-workspace-fmt = build.craneLib.cargoFmt (build.workspaceArgs // { inherit (build) src; });
komorebi-workspace-fmt = build.craneLib.cargoFmt (build.workspaceArgs // { inherit (build) src; cargoExtraArgs = build.packages; });
komorebi-workspace-toml-fmt = build.craneLib.taploFmt (
build.workspaceArgs
// {
src = pkgs.lib.sources.sourceFilesBySuffices build.src [ ".toml" ];
src = pkgs.lib.sources.sourceFilesBySuffices build.real [ ".toml" ];
}
);
# cargo deny sees every member of the workspace: leave out the other platforms' packages
# and use this tree's policy
komorebi-workspace-deny = build.craneLib.cargoDeny (
build.workspaceArgs // { inherit (build) src; }
build.workspaceArgs
// {
inherit (build) src;
cargoDenyExtraArgs =
"--workspace "
+ pkgs.lib.concatMapStringsSep " " (p: "--exclude ${p}") [
"komorebi-windows"
"komorebi-client"
"komorebi-gui"
"komorebic"
"komorebic-no-console"
"komorebi-bar"
"komorebi-shortcuts"
"komorebi-e2e-agent"
"komorebi-testwin"
"komorebi-linux"
"komorebic-linux"
"komorebi-client-linux"
"komorebi-hotkeys"
"version-linux"
];
cargoDenyChecks = "--config ${platformDir}/deny.toml bans licenses sources";
}
);
komorebi-workspace-nextest = build.craneLib.cargoNextest build.individualCrateArgs;
+36
View File
@@ -0,0 +1,36 @@
# The source of a build from the one Cargo workspace of this repository.
#
# Cargo has to load every member of the workspace, but a build of one platform needs the sources of
# that platform's crates only. `real` is the filtered source (the platform's crates, the crates of the
# root workspace they depend on, the root manifest and lock); every other member (`isReal` is false)
# is added as its own manifest with an empty library and a `main` that does nothing. An edit of a
# crate of another platform then changes nothing here, and an edit of another platform's manifest
# changes only the stub copy of it.
#
# workspaceSrc { pkgs; repoRoot; real; isReal = member: bool; }
{
pkgs,
repoRoot,
real,
isReal,
}:
let
inherit (pkgs) lib;
members = (builtins.fromTOML (builtins.readFile "${real}/Cargo.toml")).workspace.members;
stub = member: ''
mkdir -p $out/${member}/src
cp ${
builtins.path {
path = repoRoot + "/${member}/Cargo.toml";
name = "Cargo.toml";
}
} $out/${member}/Cargo.toml
: > $out/${member}/src/lib.rs
echo 'fn main() {}' > $out/${member}/src/main.rs
'';
in
pkgs.runCommand "komorebi-workspace-src" { } ''
cp -r ${real} $out
chmod -R u+w $out
${lib.concatMapStrings stub (builtins.filter (m: !(isReal m)) members)}
''