chore(repo): combine the flake phase 2 work with the integration line

Merge revision: wip-main (history merges, fixes, step 0 path dependencies, step 1 komorebi-collections, KDE A3 fixes) and wip-flake (the root flake builds the KDE package with the whole repository as source, the macOS package evaluates the same way, the root flake no longer requires dirtyRev). The root flake.lock pins the content of the nested flakes, so it is relocked in the next revision.
This commit is contained in:
LGUG2Z committed 2026-10-31 01:37:53 -07:00
commit 8c22a18dce
4 files changed
+985 -853

No files matched your search

Generated
+2 -2
View File
@@ -284,7 +284,7 @@
},
"locked": {
"lastModified": 1,
"narHash": "sha256-KjY8jnUOlUDKGebfim1z4D84bHzAYliSvue7CYbaN3E=",
"narHash": "sha256-YCSeq6arLSifLoHQi7wsJxAa3dM4suGJcxmKsOQ/tWg=",
"path": "./komorebi-for-kde",
"type": "path"
},
@@ -304,7 +304,7 @@
},
"locked": {
"lastModified": 1,
"narHash": "sha256-x4lQr5Onh7hOUASove2uGnNfItuuyTFzqBPzmUXwK9E=",
"narHash": "sha256-T8MkK2hVhFhbn044YpZGkTK3mktEbFgWQ5OqSsMCva0=",
"path": "./komorebi-for-mac",
"type": "path"
},
+41 -13
View File
@@ -16,8 +16,8 @@
flake = false;
};
# the other platforms' flakes, built from their own directories with their own locks until
# their crates depend on the ones in this tree (see the build(nix) revisions that follow)
# the other platforms' flakes: their inputs and locks are used, their outputs are made with this
# tree as the source (see the imports below)
kfde.url = "path:./komorebi-for-kde";
kfm.url = "path:./komorebi-for-mac";
};
@@ -173,7 +173,7 @@
windowsSdk,
# the commit stamped into the binaries; a build for the e2e guest
# gives a constant one, so that a new commit does not rebuild it
commit ? self.rev or (pkgs.lib.removeSuffix "-dirty" self.dirtyRev),
commit ? self.rev or (pkgs.lib.removeSuffix "-dirty" (self.dirtyRev or "unknown")),
}:
let
# toolchain with windows msvc target
@@ -298,15 +298,44 @@
inputs.treefmt-nix.flakeModule
inputs.git-hooks-nix.flakeModule
# komorebi for KDE Plasma (kfde) and komorebi for macOS (kfm), re-exported with a prefix.
# The VM tests of kfde are not re-exported as checks, so that `nix flake check` of this
# flake does not boot them; they are reachable as legacyPackages.<system>.kfde-vm.
# Their flakes keep their own inputs and lock files (inputs.<name>.inputs), but their
# outputs are made here, from the whole repository as the source: the Rust workspaces of
# both depend on the crates of this tree by path, which a flake of their own directory
# cannot see (their `lib.mkOutputs`). The VM tests of kfde are not re-exported as checks,
# so that `nix flake check` of this flake does not boot them; they are reachable as
# legacyPackages.<system>.kfde-vm.
(
{ lib, ... }:
let
# `self` of a nested flake: its own outputs, with the revision and the path of this one
nestedOutputs =
name: dir:
let
nestedSelf =
outputs
// lib.filterAttrs (n: _: n == "rev" || n == "dirtyRev") self
// {
outPath = self.outPath + "/${dir}";
inputs = inputs.${name}.inputs;
};
outputs = inputs.${name}.lib.mkOutputs {
self = nestedSelf;
inputs = inputs.${name}.inputs // {
self = nestedSelf;
};
repoRoot = self;
platformDir = dir;
};
in
outputs;
kfde = nestedOutputs "kfde" "komorebi-for-kde";
kfm = nestedOutputs "kfm" "komorebi-for-mac";
in
{
flake = {
nixosModules.komorebi-for-kde = inputs.kfde.nixosModules.default;
overlays.komorebi-for-kde = inputs.kfde.overlays.default;
darwinModules.komorebi-for-mac = inputs.kfm.darwinModules.default;
nixosModules.komorebi-for-kde = kfde.nixosModules.default;
overlays.komorebi-for-kde = kfde.overlays.default;
darwinModules.komorebi-for-mac = kfm.darwinModules.default;
};
perSystem =
@@ -317,12 +346,11 @@
in
{
packages =
prefixed "kfde" (inputs.kfde.packages.${system} or { })
// prefixed "kfm" (inputs.kfm.packages.${system} or { });
prefixed "kfde" (kfde.packages.${system} or { }) // prefixed "kfm" (kfm.packages.${system} or { });
checks =
prefixed "kfde" (withoutVmTests (inputs.kfde.checks.${system} or { }))
// prefixed "kfm" (inputs.kfm.checks.${system} or { });
legacyPackages.kfde-vm = (inputs.kfde.legacyPackages.${system} or { }).vm or { };
prefixed "kfde" (withoutVmTests (kfde.checks.${system} or { }))
// prefixed "kfm" (kfm.checks.${system} or { });
legacyPackages.kfde-vm = (kfde.legacyPackages.${system} or { }).vm or { };
};
}
)
+664 -609
View File
File diff suppressed because it is too large. Load diff
+278 -229
View File
@@ -13,249 +13,298 @@
git-hooks-nix.inputs.nixpkgs.follows = "nixpkgs";
};
# The outputs are a function of the repository they are built from, so that the root flake can
# build them with the whole repository as the source (the Rust workspace here depends on the
# crates of the root workspace by path) and with its own `self`. `lib.mkOutputs` is that function.
# The outputs of this flake on its own use the directory it is in: that evaluates everything and
# builds what is not Rust, but cannot build the Rust workspace.
outputs =
inputs@{
self,
nixpkgs,
flake-parts,
crane,
rust-overlay,
...
}:
inputs@{ self, ... }:
let
mkKomorebiPackages =
{ pkgs }:
let
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
version = "0.1.0";
src = pkgs.lib.cleanSourceWith {
src = ./.;
filter =
path: type:
(craneLib.filterCargoSources path type)
|| (pkgs.lib.hasInfix "/docs/" path)
|| (builtins.match ".*/docs/.*" path != null);
};
commonArgs = {
inherit src version;
strictDeps = true;
COMMIT_HASH = self.rev or (pkgs.lib.removeSuffix "-dirty" (self.dirtyRev or "unknown"));
nativeBuildInputs = [
pkgs.darwin.cctools
];
postFixup = ''
for bin in $out/bin/*; do
if [ -f "$bin" ] && [ -x "$bin" ]; then
# Get all linked libraries and fix libiconv references
otool -L "$bin" | grep -o '/nix/store/[^/]*/lib/libiconv[^ ]*' | while read -r lib; do
install_name_tool -change "$lib" /usr/lib/libiconv.dylib "$bin"
done
fi
done
'';
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
individualCrateArgs = commonArgs // {
inherit cargoArtifacts;
doCheck = false;
doDoc = false;
};
fullBuild = craneLib.buildPackage (
individualCrateArgs
// {
pname = "komorebi-workspace";
}
);
extractBinary =
binaryName:
pkgs.runCommand "komorebi-${binaryName}"
{
meta = fullBuild.meta // { };
}
''
mkdir -p $out/bin
cp ${fullBuild}/bin/${binaryName} $out/bin/
'';
in
mkOutputs =
{
inherit
craneLib
src
individualCrateArgs
fullBuild
inputs,
self,
# the source of the repository, and the path of this tree in it
repoRoot,
platformDir,
}:
let
inherit (inputs)
nixpkgs
flake-parts
crane
rust-overlay
;
komorebi = extractBinary "komorebi";
komorebic = extractBinary "komorebic";
komorebi-bar = extractBinary "komorebi-bar";
};
rootCrates = [
"komorebi-layouts"
"komorebi-scrolling"
"komorebi-themes"
];
mkKomorebiPackages =
{ pkgs }:
let
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
version = "0.1.0";
mkPkgs =
system:
import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
in
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"aarch64-darwin"
"x86_64-darwin"
];
# 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 {
src = repoRoot;
filter =
path: type:
let
relative = pkgs.lib.removePrefix "${toString repoRoot}/" path;
inTree =
platformDir == "" || relative == platformDir || pkgs.lib.hasPrefix "${platformDir}/" relative;
rootCrate = builtins.any (
crate: relative == crate || pkgs.lib.hasPrefix "${crate}/" relative
) rootCrates;
in
(rootCrate && !(pkgs.lib.hasSuffix "/Cargo.lock" path) || relative == "Cargo.toml" || inTree)
&& (
(craneLib.filterCargoSources path type)
|| (pkgs.lib.hasInfix "/docs/" path)
|| (builtins.match ".*/docs/.*" path != null)
);
};
imports = [
inputs.treefmt-nix.flakeModule
inputs.git-hooks-nix.flakeModule
];
# the workspace is in a subdirectory of the source, next to the crates it depends on
workspaceArgs = {
cargoLock = "${src}/${platformDir}/Cargo.lock";
cargoToml = "${src}/${platformDir}/Cargo.toml";
postUnpack = "cd $sourceRoot/${platformDir}; sourceRoot=$PWD";
};
perSystem =
{ config, system, ... }:
let
pkgs = mkPkgs system;
build = mkKomorebiPackages { inherit pkgs; };
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
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;
cargo-udeps = pkgs.writeShellScriptBin "cargo-udeps" ''
export PATH="${nightlyToolchain}/bin:$PATH"
exec ${pkgs.cargo-udeps}/bin/cargo-udeps "$@"
'';
commonArgs = workspaceArgs // {
inherit src version;
strictDeps = true;
COMMIT_HASH = self.rev or (pkgs.lib.removeSuffix "-dirty" (self.dirtyRev or "unknown"));
nativeBuildInputs = [
pkgs.darwin.cctools
];
postFixup = ''
for bin in $out/bin/*; do
if [ -f "$bin" ] && [ -x "$bin" ]; then
# Get all linked libraries and fix libiconv references
otool -L "$bin" | grep -o '/nix/store/[^/]*/lib/libiconv[^ ]*' | while read -r lib; do
install_name_tool -change "$lib" /usr/lib/libiconv.dylib "$bin"
done
fi
done
'';
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
individualCrateArgs = commonArgs // {
inherit cargoArtifacts;
doCheck = false;
doDoc = false;
};
fullBuild = craneLib.buildPackage (
individualCrateArgs
// {
pname = "komorebi-workspace";
}
);
extractBinary =
binaryName:
pkgs.runCommand "komorebi-${binaryName}"
{
meta = fullBuild.meta // { };
}
''
mkdir -p $out/bin
cp ${fullBuild}/bin/${binaryName} $out/bin/
'';
in
{
inherit
craneLib
src
workspaceArgs
individualCrateArgs
fullBuild
;
komorebi = extractBinary "komorebi";
komorebic = extractBinary "komorebic";
komorebi-bar = extractBinary "komorebi-bar";
};
mkPkgs =
system:
import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
in
{
treefmt = {
projectRootFile = "flake.nix";
programs = {
deadnix.enable = true;
just.enable = true;
nixfmt.enable = true;
taplo.enable = true;
rustfmt = {
enable = true;
package = pkgs.rust-bin.nightly.latest.rustfmt;
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"aarch64-darwin"
"x86_64-darwin"
];
imports = [
inputs.treefmt-nix.flakeModule
inputs.git-hooks-nix.flakeModule
];
perSystem =
{ config, system, ... }:
let
pkgs = mkPkgs system;
build = mkKomorebiPackages { inherit pkgs; };
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
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;
cargo-udeps = pkgs.writeShellScriptBin "cargo-udeps" ''
export PATH="${nightlyToolchain}/bin:$PATH"
exec ${pkgs.cargo-udeps}/bin/cargo-udeps "$@"
'';
in
{
treefmt = {
projectRootFile = "flake.nix";
programs = {
deadnix.enable = true;
just.enable = true;
nixfmt.enable = true;
taplo.enable = true;
rustfmt = {
enable = true;
package = pkgs.rust-bin.nightly.latest.rustfmt;
};
};
};
checks = {
komorebi-workspace-clippy = build.craneLib.cargoClippy build.individualCrateArgs;
komorebi-workspace-fmt = build.craneLib.cargoFmt (build.workspaceArgs // { inherit (build) src; });
komorebi-workspace-toml-fmt = build.craneLib.taploFmt (
build.workspaceArgs
// {
src = pkgs.lib.sources.sourceFilesBySuffices build.src [ ".toml" ];
}
);
komorebi-workspace-deny = build.craneLib.cargoDeny (
build.workspaceArgs // { inherit (build) src; }
);
komorebi-workspace-nextest = build.craneLib.cargoNextest build.individualCrateArgs;
nix-options-validation = import ./nix/tests { inherit pkgs; };
darwin-module-validation = import ./nix/tests/darwin-module.nix { inherit pkgs; };
};
packages = {
inherit (build) komorebi komorebic komorebi-bar;
komorebi-full = build.fullBuild;
default = build.fullBuild;
};
apps = {
komorebi = {
type = "app";
program = "${build.komorebi}/bin/komorebi";
};
komorebic = {
type = "app";
program = "${build.komorebic}/bin/komorebic";
};
komorebi-bar = {
type = "app";
program = "${build.komorebi-bar}/bin/komorebi-bar";
};
default = {
type = "app";
program = "${build.fullBuild}/bin/komorebi";
};
};
devShells.default = pkgs.mkShell {
name = "komorebi";
RUST_BACKTRACE = "full";
inputsFrom = [ build.fullBuild ];
packages = [
rustToolchainWithNightlyRustfmt
cargo-udeps
pkgs.cargo-deny
pkgs.cargo-nextest
pkgs.cargo-outdated
pkgs.jq
pkgs.just
pkgs.prettier
pkgs.wrangler
];
};
pre-commit = {
check.enable = true;
settings.hooks.treefmt = {
enable = true;
package = config.treefmt.build.wrapper;
pass_filenames = false;
};
};
};
};
checks = {
komorebi-workspace-clippy = build.craneLib.cargoClippy build.individualCrateArgs;
flake = {
overlays.default =
final: _:
let
pkgs = mkPkgs final.system;
build = mkKomorebiPackages {
inherit pkgs;
};
in
{
inherit (build) komorebi komorebic komorebi-bar;
komorebi-full = build.fullBuild;
};
komorebi-workspace-fmt = build.craneLib.cargoFmt {
inherit (build) src;
};
overlays.komorebi =
final: _:
let
pkgs = mkPkgs final.system;
build = mkKomorebiPackages {
inherit pkgs;
};
in
{
inherit (build) komorebi komorebic komorebi-bar;
komorebi-full = build.fullBuild;
};
komorebi-workspace-toml-fmt = build.craneLib.taploFmt {
src = pkgs.lib.sources.sourceFilesBySuffices build.src [ ".toml" ];
};
komorebi-workspace-deny = build.craneLib.cargoDeny {
inherit (build) src;
};
komorebi-workspace-nextest = build.craneLib.cargoNextest build.individualCrateArgs;
nix-options-validation = import ./nix/tests { inherit pkgs; };
darwin-module-validation = import ./nix/tests/darwin-module.nix { inherit pkgs; };
};
packages = {
inherit (build) komorebi komorebic komorebi-bar;
komorebi-full = build.fullBuild;
default = build.fullBuild;
};
apps = {
komorebi = {
type = "app";
program = "${build.komorebi}/bin/komorebi";
};
komorebic = {
type = "app";
program = "${build.komorebic}/bin/komorebic";
};
komorebi-bar = {
type = "app";
program = "${build.komorebi-bar}/bin/komorebi-bar";
};
default = {
type = "app";
program = "${build.fullBuild}/bin/komorebi";
};
};
devShells.default = pkgs.mkShell {
name = "komorebi";
RUST_BACKTRACE = "full";
inputsFrom = [ build.fullBuild ];
packages = [
rustToolchainWithNightlyRustfmt
cargo-udeps
pkgs.cargo-deny
pkgs.cargo-nextest
pkgs.cargo-outdated
pkgs.jq
pkgs.just
pkgs.prettier
pkgs.wrangler
];
};
pre-commit = {
check.enable = true;
settings.hooks.treefmt = {
enable = true;
package = config.treefmt.build.wrapper;
pass_filenames = false;
};
darwinModules.default = import ./nix/darwin-module.nix;
darwinModules.komorebi = import ./nix/darwin-module.nix;
};
};
flake = {
overlays.default =
final: _:
let
pkgs = mkPkgs final.system;
build = mkKomorebiPackages {
inherit pkgs;
};
in
{
inherit (build) komorebi komorebic komorebi-bar;
komorebi-full = build.fullBuild;
};
overlays.komorebi =
final: _:
let
pkgs = mkPkgs final.system;
build = mkKomorebiPackages {
inherit pkgs;
};
in
{
inherit (build) komorebi komorebic komorebi-bar;
komorebi-full = build.fullBuild;
};
darwinModules.default = import ./nix/darwin-module.nix;
darwinModules.komorebi = import ./nix/darwin-module.nix;
};
in
mkOutputs {
inherit inputs self;
repoRoot = ./.;
platformDir = "";
}
// {
lib.mkOutputs = mkOutputs;
};
}