Files
komorebi/nix/lib.nix
T
LGUG2Z ae9ee327f9 build(nix): one root flake for Windows, KDE Plasma and macOS
One flake.nix and one flake.lock replace the root flake that re-exported two nested flakes.
The inputs are one nixpkgs (the revision the KDE flake was locked to, f05535a0: the VM suites
run against its Plasma and KWin 6.8.2), one crane, rust-overlay (19ecdd08, rustc 1.99.1),
flake-parts, treefmt-nix and git-hooks-nix, all the KDE flake revisions, plus asc. A second
nixpkgs, nixpkgs-x86_64-darwin (16c7794d, the macOS flake pin), serves the x86_64-darwin
outputs only: evaluating that system with the unified pin throws (nixpkgs 26.11 dropped it).

Layout: nix/common.nix (systems, pkgs, treefmt, pre-commit, dev shells default and native,
default overlay), nix/lib.nix, nix/workspace-src.nix (one source per platform from the one Cargo
workspace: the platform members, its files of the shared crates told apart by name, the data
files, and stubs for the other members, which cargo needs), nix/{windows,linux,macos}/
{build,flake-module}.nix. The dependency derivations use a manifests-only dummy source, a plain
path, so crane reads nothing built at evaluation and the Darwin outputs evaluate on Linux.

Names: unprefixed outputs are the native build (Linux: KDE; Darwin: macOS); Windows cross
outputs are windows-*; checks are windows-*, linux-*, macos-* and vm-NAME; table in docs/dev/flake.md
(next revision). One deny.toml, one format-all and one version (workspace) are used by all.
PLACEHOLDER for the agent that owns the check sets: the checks that evaluate a NixOS system
or a VM (vm-*, linux-nixos-module-eval, linux-plasma-guests-eval, linux-run-kde*) are
legacyPackages.<system>.heavyChecks.<name>, not checks, because evaluating them needs more
memory than nix flake check --all-systems can use. The Plasma guests got a stub root file system
and boot loader (mkDefault, replaced by their vmVariant) so that nix flake check can evaluate
their toplevel.

Verified: nix flake check --no-build --all-systems passes (42 s, rc 0); nix flake check
--no-build passes. Not verified: any build (next revisions record them).
2026-11-05 15:03:27 -08:00

66 lines
2.2 KiB
Nix

# Helpers shared by the platform modules of the flake.
{ inputs }:
rec {
# the repository, as the source of the flake
repoRoot = ./..;
# a file or directory of the repository as a store path of its own: `./tools/format-all` would name
# a place in the store path of the whole flake source, which changes with every edit of the
# repository and so would rebuild the derivation that reads it
repoFile =
rel:
builtins.path {
path = repoRoot + "/${rel}";
name = builtins.baseNameOf rel;
};
# the version of the workspace: every package says `version.workspace = true`
version =
(builtins.fromTOML (builtins.readFile (repoRoot + "/Cargo.toml"))).workspace.package.version;
# the systems that cross-build for Windows, build the Linux packages and build the macOS packages
windowsSystems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
linuxSystems = [
"x86_64-linux"
"aarch64-linux"
];
# Apple silicon also gets the checks of the KDE crates (they run against a fake desktop)
linuxCheckSystems = linuxSystems ++ [ "aarch64-darwin" ];
macosSystems = [
"aarch64-darwin"
"x86_64-darwin"
];
# The manifests (Cargo.toml, Cargo.lock, build scripts, .cargo/config.toml) of every member of the
# workspace, of all three platforms, and nothing else: crane makes the dummy source of the dependency
# derivations from it. A pure path (no derivation), so that crane reads it at evaluation without
# building anything, which `nix flake check --all-systems` needs on a host that cannot build for the
# other systems; and the same for every platform, so that the dependencies do not depend on the stubs.
manifestSource =
lib:
lib.fileset.toSource {
root = repoRoot;
fileset = lib.fileset.fileFilter (
file:
builtins.elem file.name [
"Cargo.toml"
"Cargo.lock"
"build.rs"
"config.toml"
]
) repoRoot;
};
# nixpkgs with the rust overlay, for a system (x86_64-darwin: see the input nixpkgs-x86_64-darwin)
mkPkgs =
system:
import (if system == "x86_64-darwin" then inputs.nixpkgs-x86_64-darwin else inputs.nixpkgs) {
inherit system;
overlays = [ (import inputs.rust-overlay) ];
};
}