mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-18 22:58:34 +01:00
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).
207 lines
6.3 KiB
Nix
207 lines
6.3 KiB
Nix
# What the three platforms share: the systems, nixpkgs with the rust overlay, the formatter, the
|
|
# pre-commit hook and the dev shell.
|
|
{ inputs, self, ... }:
|
|
let
|
|
lib' = import ./lib.nix { inherit inputs; };
|
|
in
|
|
{
|
|
imports = [
|
|
# pkgs of every perSystem module (a module of its own: one that takes `pkgs` cannot define it)
|
|
{
|
|
perSystem =
|
|
{ system, ... }:
|
|
{
|
|
_module.args.pkgs = lib'.mkPkgs system;
|
|
};
|
|
}
|
|
inputs.treefmt-nix.flakeModule
|
|
inputs.git-hooks-nix.flakeModule
|
|
];
|
|
|
|
# Linux and Windows (cross) builds on both Linux architectures, macOS on both Apple ones.
|
|
# x86_64-darwin uses an older nixpkgs (flake.nix, input nixpkgs-x86_64-darwin).
|
|
systems = [
|
|
"x86_64-linux"
|
|
"aarch64-linux"
|
|
"aarch64-darwin"
|
|
"x86_64-darwin"
|
|
];
|
|
|
|
flake = {
|
|
# the packages of the platform of the system the overlay is applied to: the Linux ones (overlays.linux,
|
|
# nix/linux/flake-module.nix) or the macOS ones (overlays.macos)
|
|
overlays.default =
|
|
final: prev:
|
|
(if final.stdenv.hostPlatform.isDarwin then self.overlays.macos else self.overlays.linux) final
|
|
prev;
|
|
overlays.komorebi = self.overlays.default;
|
|
};
|
|
|
|
perSystem =
|
|
{
|
|
config,
|
|
pkgs,
|
|
system,
|
|
msvcEnv,
|
|
ovmfWithTpm,
|
|
...
|
|
}:
|
|
let
|
|
crossToWindows = builtins.elem system lib'.windowsSystems;
|
|
# the toolchain of rust-toolchain.toml, with the Windows target on the systems that cross-build
|
|
rustToolchain =
|
|
let
|
|
stable = pkgs.rust-bin.fromRustupToolchainFile ../rust-toolchain.toml;
|
|
in
|
|
if crossToWindows then stable.override { targets = [ "x86_64-pc-windows-msvc" ]; } else stable;
|
|
nightlyRustfmt = pkgs.rust-bin.nightly.latest.rustfmt;
|
|
rustToolchainWithNightlyRustfmt = pkgs.symlinkJoin {
|
|
name = "rust-toolchain-with-nightly-rustfmt";
|
|
paths = [
|
|
nightlyRustfmt
|
|
rustToolchain
|
|
];
|
|
};
|
|
nightlyToolchain = pkgs.rust-bin.nightly.latest.default.override {
|
|
targets = pkgs.lib.optional crossToWindows "x86_64-pc-windows-msvc";
|
|
};
|
|
# cargo-udeps needs a nightly compiler
|
|
cargo-udeps = pkgs.writeShellScriptBin "cargo-udeps" ''
|
|
export PATH="${nightlyToolchain}/bin:$PATH"
|
|
exec ${pkgs.cargo-udeps}/bin/cargo-udeps "$@"
|
|
'';
|
|
|
|
# the tools of every platform's development
|
|
tools = [
|
|
rustToolchainWithNightlyRustfmt
|
|
cargo-udeps
|
|
|
|
# cross-compilation tooling for Windows (xwin): clang-cl, lld-link, llvm-lib
|
|
pkgs.llvmPackages.clang-unwrapped
|
|
pkgs.llvmPackages.lld
|
|
pkgs.llvmPackages.llvm
|
|
|
|
# komorebic's build script (reqwest) runs on the build host
|
|
pkgs.pkg-config
|
|
pkgs.openssl
|
|
|
|
pkgs.cargo-deny
|
|
pkgs.cargo-nextest
|
|
pkgs.cargo-outdated
|
|
pkgs.check-jsonschema
|
|
pkgs.jq
|
|
pkgs.just
|
|
pkgs.prettier
|
|
pkgs.ripgrep
|
|
|
|
# the tests of the sleep and lock signals of the KDE daemon start private buses (`kwin::power`)
|
|
pkgs.dbus
|
|
|
|
# the KDE bridge's type check and tests (`just check-js`)
|
|
pkgs.nodejs
|
|
pkgs.typescript
|
|
|
|
# the VM test library of the KDE suites
|
|
pkgs.ruff
|
|
pkgs.ty
|
|
|
|
# the Windows e2e guest (e2e/platforms/qemu_windows) and the tests of e2e/lib
|
|
pkgs.qemu
|
|
pkgs.swtpm
|
|
pkgs.xorriso
|
|
pkgs.socat
|
|
pkgs.git
|
|
(pkgs.python3.withPackages (p: [
|
|
p.pillow
|
|
p.pytest
|
|
]))
|
|
]
|
|
# publishes the schema site of the macOS tree
|
|
++ pkgs.lib.optional pkgs.stdenv.hostPlatform.isDarwin pkgs.wrangler;
|
|
|
|
mkDevShell =
|
|
{
|
|
name,
|
|
# the cross-compilation environment of the Windows build: CARGO_BUILD_TARGET makes every
|
|
# `cargo` command build for Windows, so a shell that builds the Linux or macOS packages
|
|
# natively leaves it out
|
|
cross,
|
|
}:
|
|
pkgs.mkShell (
|
|
{
|
|
inherit name;
|
|
|
|
RUST_BACKTRACE = "full";
|
|
|
|
# komorebic's build script runs on the host and wants OpenSSL, as in
|
|
# the nix build
|
|
OPENSSL_NO_VENDOR = "1";
|
|
OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib";
|
|
OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include";
|
|
|
|
packages = tools;
|
|
}
|
|
// pkgs.lib.optionalAttrs (crossToWindows) {
|
|
# the Windows e2e guest (e2e/platforms/qemu_windows): the build
|
|
# scripts and the runner find OVMF here, and the vendored core
|
|
# and the platform on PYTHONPATH
|
|
OVMF_FD = "${ovmfWithTpm}";
|
|
shellHook = ''
|
|
export PYTHONPATH="$PWD/e2e/lib:$PWD/e2e''${PYTHONPATH:+:$PYTHONPATH}"
|
|
'';
|
|
}
|
|
// pkgs.lib.optionalAttrs (cross && crossToWindows) {
|
|
# cross-compilation environment
|
|
inherit (msvcEnv)
|
|
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER
|
|
CC_x86_64_pc_windows_msvc
|
|
CXX_x86_64_pc_windows_msvc
|
|
AR_x86_64_pc_windows_msvc
|
|
CFLAGS_x86_64_pc_windows_msvc
|
|
CXXFLAGS_x86_64_pc_windows_msvc
|
|
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS
|
|
CARGO_BUILD_TARGET
|
|
;
|
|
}
|
|
);
|
|
in
|
|
{
|
|
treefmt = {
|
|
projectRootFile = "flake.nix";
|
|
programs = {
|
|
deadnix.enable = true;
|
|
just.enable = true;
|
|
nixfmt.enable = true;
|
|
taplo.enable = true;
|
|
rustfmt = {
|
|
enable = true;
|
|
package = nightlyRustfmt;
|
|
};
|
|
};
|
|
};
|
|
|
|
# `nix develop`: everything the three platforms need, and the Windows cross-compilation
|
|
# environment (cargo builds for x86_64-pc-windows-msvc by default). `nix develop .#native` is the
|
|
# same without it, for `cargo` commands on the Linux or macOS packages (-p komorebi-linux, ...).
|
|
devShells = {
|
|
default = mkDevShell {
|
|
name = "komorebi";
|
|
cross = true;
|
|
};
|
|
native = mkDevShell {
|
|
name = "komorebi-native";
|
|
cross = false;
|
|
};
|
|
};
|
|
|
|
pre-commit = {
|
|
check.enable = true;
|
|
settings.hooks.treefmt = {
|
|
enable = true;
|
|
package = config.treefmt.build.wrapper;
|
|
pass_filenames = false;
|
|
};
|
|
};
|
|
};
|
|
}
|