Files
komorebi/nix/workspace-src.nix
T
LGUG2Z 80a749b37e 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.
2026-10-31 12:06:27 -07:00

37 lines
1.3 KiB
Nix

# 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)}
''