mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-15 21:32:26 +01:00
refactor(nix): delete the nested flakes
komorebi-for-kde/flake.nix, komorebi-for-kde/flake.lock, komorebi-for-mac/flake.nix and komorebi-for-mac/flake.lock: the root flake builds both platforms now, from one source and one lock. The directories komorebi-for-kde/ and komorebi-for-mac/ are gone with them. Verified: nix flake check --no-build --all-systems passes without them (it did not read them after the previous revision either).
This commit is contained in:
1 parent
ae9ee327f9
commit
333624efa8
4 files changed
-1565
No files matched your search
Generated
-157
@@ -1,157 +0,0 @@
|
||||
{
|
||||
"nodes": {
|
||||
"crane": {
|
||||
"locked": {
|
||||
"lastModified": 1792350552,
|
||||
"narHash": "sha256-292lvpvxTGKryKxh3/3tcIVi85CwYGdl4oOi113Sob8=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "e675a36b7377bebe41d548388a2501cbb16d380d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1767039857,
|
||||
"narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=",
|
||||
"owner": "NixOS",
|
||||
"repo": "flake-compat",
|
||||
"rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1790898470,
|
||||
"narHash": "sha256-zTwuwezD0w3hpga6a6P8emidzAZFyWqlNeRBlpWOOl8=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "024633cd702b10285db5cb19b40ad48d2399ba60",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"git-hooks-nix": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1791909798,
|
||||
"narHash": "sha256-VAhpCOmrun/KXimYfR8NM88bciKCui7CqHHhThSzgag=",
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"rev": "1ba1dbfe28738c9a71c266be6efa5b89e75491a9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1793136825,
|
||||
"narHash": "sha256-2pkE69JpFRInaARSczZytcfPw83IL82E2KdhbWGwdMs=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "f05535a0efcb2134c478d1e88434fadf486d42b5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"lastModified": 1790477367,
|
||||
"narHash": "sha256-oujbxmVKDhci2E4EM3KyAbRUgp5/IsCoiA/LfEF7OOk=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "f7cd230690d9fc982d06129f9189b101fddcfa3b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"crane": "crane",
|
||||
"flake-parts": "flake-parts",
|
||||
"git-hooks-nix": "git-hooks-nix",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay",
|
||||
"treefmt-nix": "treefmt-nix"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1793174968,
|
||||
"narHash": "sha256-u5nUf4cewaT36iIzG1s/VECktqUMiZaGF5BsgervsvQ=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "19ecdd08213836b36c4296a3a4f4af5a3d5308db",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"treefmt-nix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1791885023,
|
||||
"narHash": "sha256-C3alQ2MEt0zVrUSho5NUDo3jmhbff72++bfwoqT9Omo=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "0d6d739a833ba9a9c93034862e4a7b061a062a1c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
@@ -1,803 +0,0 @@
|
||||
{
|
||||
description = "komorebi for KDE Plasma";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
crane.url = "github:ipetkov/crane";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
||||
treefmt-nix.url = "github:numtide/treefmt-nix";
|
||||
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
|
||||
git-hooks-nix.url = "github:cachix/git-hooks.nix";
|
||||
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, ... }:
|
||||
let
|
||||
mkOutputs =
|
||||
{
|
||||
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
|
||||
;
|
||||
# the crates of the root workspace that this workspace depends on, by path, directly or not.
|
||||
# Only these are in the source, so that an edit of another crate (the bar's) changes nothing
|
||||
# here. `tools/kde-closure-check` fails if this list and `cargo metadata` differ.
|
||||
rootCrates = builtins.fromJSON (builtins.readFile ./nix/root-crates.json);
|
||||
mkPkgs =
|
||||
system:
|
||||
import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ (import rust-overlay) ];
|
||||
};
|
||||
|
||||
mkKomorebiPackages =
|
||||
{ pkgs }:
|
||||
let
|
||||
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
|
||||
# rustfmt.toml uses options only a nightly rustfmt knows
|
||||
fmtToolchain = pkgs.rust-bin.nightly.latest.minimal.override { extensions = [ "rustfmt" ]; };
|
||||
craneLibFmt = (crane.mkLib pkgs).overrideToolchain fmtToolchain;
|
||||
|
||||
# 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
|
||||
real = 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;
|
||||
# the directory that holds the crates of crates/, to reach the listed ones
|
||||
rootCrateParent = relative == "crates";
|
||||
# the unified komorebic package: its manifest, build script, main and the Linux module
|
||||
# and tests; not the Windows and macOS files
|
||||
komorebic =
|
||||
builtins.elem relative [
|
||||
"komorebic"
|
||||
"komorebic/Cargo.toml"
|
||||
"komorebic/build.rs"
|
||||
"komorebic/src"
|
||||
"komorebic/src/main.rs"
|
||||
"komorebic/tests"
|
||||
]
|
||||
|| pkgs.lib.hasPrefix "komorebic/src/linux" relative
|
||||
|| pkgs.lib.hasPrefix "komorebic/tests/linux_" relative;
|
||||
# the unified komorebi-client package: its manifest, lib.rs, the Linux module and tests
|
||||
komorebiClient =
|
||||
builtins.elem relative [
|
||||
"komorebi-client"
|
||||
"komorebi-client/Cargo.toml"
|
||||
"komorebi-client/src"
|
||||
"komorebi-client/src/lib.rs"
|
||||
"komorebi-client/src/linux.rs"
|
||||
"komorebi-client/tests"
|
||||
]
|
||||
|| pkgs.lib.hasPrefix "komorebi-client/tests/linux_" relative;
|
||||
|
||||
# the one komorebi binary package: its manifest, main.rs and tests
|
||||
komorebiDaemon =
|
||||
builtins.elem relative [
|
||||
"komorebi-daemon"
|
||||
"komorebi-daemon/Cargo.toml"
|
||||
"komorebi-daemon/src"
|
||||
"komorebi-daemon/src/main.rs"
|
||||
"komorebi-daemon/tests"
|
||||
]
|
||||
|| pkgs.lib.hasPrefix "komorebi-daemon/tests/linux_" relative;
|
||||
in
|
||||
((rootCrate || rootCrateParent || komorebic || komorebiClient || komorebiDaemon) && !(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
|
||||
!(pkgs.lib.hasInfix "/nix/tests/vm/" path)
|
||||
&& (
|
||||
(craneLib.filterCargoSources path type)
|
||||
# the script komorebi loads into KWin, which the daemon includes
|
||||
|| (pkgs.lib.hasSuffix ".js" path)
|
||||
# the messages the tests of the bridge and of the daemon share, the configurations
|
||||
# the tests load, and the schemas
|
||||
|| (pkgs.lib.hasSuffix ".json" path)
|
||||
# the page of the docs that shows the example configuration, which a test compares
|
||||
# with the example file
|
||||
|| (pkgs.lib.hasSuffix "docs/example-configurations.md" path)
|
||||
# the example a test loads, to see that the docs show one that works
|
||||
|| (pkgs.lib.hasSuffix "docs/usage/wallpapers.md" path)
|
||||
# the sample key bindings that `komorebic quickstart` includes
|
||||
|| (pkgs.lib.hasSuffix "docs/skhdrc.sample" path)
|
||||
# the key binding files the komorebi-hotkeys tests read
|
||||
|| (pkgs.lib.hasInfix "/komorebi-hotkeys/tests/fixtures/" path)
|
||||
);
|
||||
};
|
||||
|
||||
# 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
|
||||
|| member == "komorebic"
|
||||
|| member == "komorebi-client"
|
||||
|| member == "komorebi-daemon"
|
||||
|| builtins.any (crate: member == crate || pkgs.lib.hasPrefix "${crate}/" member) rootCrates;
|
||||
};
|
||||
lockFile = builtins.path {
|
||||
path = repoRoot + "/Cargo.lock";
|
||||
name = "Cargo.lock";
|
||||
};
|
||||
tomlFile = builtins.path {
|
||||
path = repoRoot + "/Cargo.toml";
|
||||
name = "Cargo.toml";
|
||||
};
|
||||
packages = "-p komorebi -p komorebi-linux -p komorebic -p komorebi-client -p komorebi-hotkeys";
|
||||
workspaceArgs = {
|
||||
pname = "komorebi-workspace";
|
||||
version = (builtins.fromTOML (builtins.readFile ./komorebi/Cargo.toml)).package.version;
|
||||
# the lock and the root manifest as files of their own: a path inside the filtered source
|
||||
# would put all of it into the context of every derivation, and an edit of any file
|
||||
# would then change the dependencies
|
||||
cargoLock = lockFile;
|
||||
cargoToml = tomlFile;
|
||||
cargoVendorDir = craneLib.vendorCargoDeps { cargoLock = lockFile; };
|
||||
};
|
||||
|
||||
commonArgs = workspaceArgs // {
|
||||
cargoExtraArgs = "--locked ${packages}";
|
||||
inherit src;
|
||||
pname = "komorebi-workspace";
|
||||
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
|
||||
# build below knows the real one.
|
||||
COMMIT_HASH = "nix-check";
|
||||
};
|
||||
|
||||
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
||||
|
||||
individualCrateArgs = commonArgs // {
|
||||
inherit cargoArtifacts;
|
||||
doCheck = false;
|
||||
doDoc = false;
|
||||
};
|
||||
|
||||
fullBuild = craneLib.buildPackage (
|
||||
individualCrateArgs
|
||||
// {
|
||||
COMMIT_HASH = self.rev or (pkgs.lib.removeSuffix "-dirty" (self.dirtyRev or "unknown"));
|
||||
}
|
||||
);
|
||||
|
||||
# the same build with the constant commit of the checks: the VM tests install this one, so
|
||||
# that a new commit does not build the daemon again
|
||||
vmBuild = craneLib.buildPackage individualCrateArgs;
|
||||
|
||||
extractBinaryOf =
|
||||
package: binaryName:
|
||||
pkgs.runCommand "komorebi-${binaryName}" { meta = package.meta // { }; } ''
|
||||
mkdir -p $out/bin
|
||||
cp ${package}/bin/${binaryName} $out/bin/
|
||||
'';
|
||||
extractBinary = extractBinaryOf fullBuild;
|
||||
in
|
||||
{
|
||||
inherit
|
||||
craneLib
|
||||
craneLibFmt
|
||||
fmtToolchain
|
||||
src
|
||||
real
|
||||
workspaceArgs
|
||||
packages
|
||||
commonArgs
|
||||
individualCrateArgs
|
||||
fullBuild
|
||||
vmBuild
|
||||
;
|
||||
komorebi = extractBinary "komorebi";
|
||||
komorebic = extractBinary "komorebic";
|
||||
komorebiForVm = extractBinaryOf vmBuild "komorebi";
|
||||
komorebicForVm = extractBinaryOf vmBuild "komorebic";
|
||||
# komorebic with the constant commit of the checks, whose output the schemas are
|
||||
# checked against: it is the same for every commit
|
||||
komorebicForChecks = craneLib.buildPackage (
|
||||
individualCrateArgs
|
||||
// {
|
||||
pname = "komorebic-for-checks";
|
||||
cargoExtraArgs = "--package komorebic --bin komorebic";
|
||||
}
|
||||
);
|
||||
};
|
||||
in
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
# Linux is what komorebi runs on. An Apple silicon Mac gets the dev shell, the formatter and the
|
||||
# checks, which run the same tests against the fake desktop. nixpkgs dropped x86_64-darwin in
|
||||
# 26.11.
|
||||
systems = [
|
||||
"aarch64-linux"
|
||||
"x86_64-linux"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
|
||||
imports = [
|
||||
inputs.treefmt-nix.flakeModule
|
||||
inputs.git-hooks-nix.flakeModule
|
||||
];
|
||||
|
||||
perSystem =
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
system,
|
||||
...
|
||||
}:
|
||||
let
|
||||
pkgs = mkPkgs system;
|
||||
build = mkKomorebiPackages { inherit pkgs; };
|
||||
isLinux = pkgs.stdenv.hostPlatform.isLinux;
|
||||
# the guests install komorebi through the module, as a NixOS user does
|
||||
komorebiModule = self.nixosModules.forVmTests;
|
||||
# a Mac runs the guests under HVF, which is slower than KVM. A Linux host is no faster
|
||||
# than a Mac to the suites that time the daemon: on a 24-core WSL2 machine, under nested
|
||||
# KVM and with nothing else running, `latency` measured a p95 of 129 ms against its
|
||||
# 100 ms times `scale`, where x86-1 had passed it at 1
|
||||
vm = import ./nix/tests/vm {
|
||||
hostPkgs = pkgs;
|
||||
inherit komorebiModule;
|
||||
scale = 1.5;
|
||||
};
|
||||
# the probe of a NixOS-WSL2 machine (docs/dev/wsl2-probe.md); the checks use a constant
|
||||
# revision, so that they are the same derivations for every commit
|
||||
wsl2Probe = import ./nix/dev/wsl2-probe.nix {
|
||||
inherit pkgs;
|
||||
rev = self.rev or self.dirtyRev or "unknown";
|
||||
};
|
||||
wsl2ProbeForChecks = import ./nix/dev/wsl2-probe.nix {
|
||||
inherit pkgs;
|
||||
rev = "nix-check";
|
||||
};
|
||||
# `run-kde` starts the demo guest of the host's architecture (docs/trying-it.md). The guest's
|
||||
# runner is named in the program, not depended on: the command works out what is missing
|
||||
# and builds it, with its progress shown, instead of `nix run` fetching 4 GB first.
|
||||
runKde =
|
||||
let
|
||||
arch = if system == "x86_64-linux" then "x86_64" else "aarch64";
|
||||
guest = self.nixosConfigurations."run-kde-${arch}";
|
||||
runner = builtins.unsafeDiscardStringContext "${guest.config.system.build.vm}";
|
||||
in
|
||||
pkgs.writeShellApplication {
|
||||
name = "run-kde";
|
||||
runtimeInputs = with pkgs; [
|
||||
coreutils
|
||||
e2fsprogs
|
||||
gawk
|
||||
git
|
||||
gnugrep
|
||||
gnused
|
||||
mesa-demos
|
||||
openssh
|
||||
qemu-utils
|
||||
virtiofsd
|
||||
];
|
||||
text = ''
|
||||
: "''${RUN_KDE_GUEST:=run-kde-${arch}}"
|
||||
: "''${RUN_KDE_RUNNER_BIN:=${runner}/bin/run-${guest.config.networking.hostName}-vm}"
|
||||
''
|
||||
+ builtins.readFile ./scripts/run-kde;
|
||||
};
|
||||
nightlyRustfmt = pkgs.rust-bin.nightly.latest.rustfmt;
|
||||
nightlyToolchain = pkgs.rust-bin.nightly.latest.default;
|
||||
rustToolchainWithNightlyRustfmt = pkgs.symlinkJoin {
|
||||
name = "rust-toolchain-with-nightly-rustfmt";
|
||||
paths = [
|
||||
nightlyRustfmt
|
||||
(pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml)
|
||||
];
|
||||
};
|
||||
# cargo-udeps needs a nightly compiler
|
||||
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 = nightlyRustfmt;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
checks = {
|
||||
# tools/format-all --tree kde: the nightly rustfmt over the files of this tree, file by file. `cargo fmt`
|
||||
# followed `mod windows;` of the shared entry files into files this source does not have.
|
||||
komorebi-workspace-fmt =
|
||||
pkgs.runCommand "komorebi-workspace-fmt"
|
||||
{
|
||||
nativeBuildInputs = [ build.fmtToolchain ];
|
||||
}
|
||||
''
|
||||
RUSTFMT=rustfmt bash ${builtins.path { path = repoRoot + "/tools/format-all"; name = "format-all"; }} --check --tree kde --root ${build.real}
|
||||
touch $out
|
||||
'';
|
||||
|
||||
komorebi-workspace-clippy = build.craneLib.cargoClippy (
|
||||
build.individualCrateArgs
|
||||
// {
|
||||
cargoClippyExtraArgs = "--all-targets -- -D warnings";
|
||||
}
|
||||
);
|
||||
|
||||
komorebi-workspace-doc = build.craneLib.cargoDoc (
|
||||
build.individualCrateArgs
|
||||
// {
|
||||
cargoDocExtraArgs = "--no-deps";
|
||||
env.RUSTDOCFLAGS = "-D warnings";
|
||||
}
|
||||
);
|
||||
|
||||
komorebi-workspace-toml-fmt = build.craneLib.taploFmt (
|
||||
build.workspaceArgs
|
||||
// {
|
||||
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;
|
||||
cargoDenyExtraArgs =
|
||||
"--workspace "
|
||||
+ lib.concatMapStringsSep " " (p: "--exclude ${p}") [
|
||||
"komorebi-bar-core"
|
||||
"komorebi-windows"
|
||||
"komorebi-gui"
|
||||
"komorebic-no-console"
|
||||
"komorebi-bar"
|
||||
"komorebi-shortcuts"
|
||||
"komorebi-e2e-agent"
|
||||
"komorebi-testwin"
|
||||
"komorebi-macos"
|
||||
"komorebic-macos"
|
||||
"komorebi-client-macos"
|
||||
"komorebi-bar-macos"
|
||||
"version-macos"
|
||||
]
|
||||
# --config is an option of `cargo deny`, not of `check`, in the cargo-deny of this flake's nixpkgs
|
||||
+ " --config ${platformDir}/deny.toml";
|
||||
cargoDenyChecks = "bans licenses sources";
|
||||
}
|
||||
);
|
||||
|
||||
komorebi-workspace-nextest = build.craneLib.cargoNextest (
|
||||
build.individualCrateArgs // { doCheck = true; }
|
||||
);
|
||||
|
||||
# The bridge is not Rust: tsc checks its types from its JSDoc comments, and node runs
|
||||
# its tests against a fake KWin. No package.json and no build step.
|
||||
komorebi-bridge-js =
|
||||
pkgs.runCommand "komorebi-bridge-js"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
pkgs.nodejs
|
||||
pkgs.typescript
|
||||
];
|
||||
src = lib.fileset.toSource {
|
||||
root = ./komorebi/src/kwin;
|
||||
fileset = lib.fileset.fileFilter (file: !file.hasExt "rs") ./komorebi/src/kwin;
|
||||
};
|
||||
}
|
||||
''
|
||||
cd $src
|
||||
tsc -p tsconfig.json
|
||||
node --test bridge.test.js
|
||||
touch $out
|
||||
'';
|
||||
|
||||
vm-lib = vm.lib;
|
||||
|
||||
# The schemas, the options made from one of them and the example are what the Rust types
|
||||
# say: `just jsonschema` and `just nixgen` write them
|
||||
schema-fresh =
|
||||
pkgs.runCommand "komorebi-schema-fresh"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
build.komorebicForChecks
|
||||
pkgs.diffutils
|
||||
];
|
||||
}
|
||||
''
|
||||
komorebic static-config-schema | diff -u ${./schema.json} - \
|
||||
|| { echo "schema.json is stale: run just jsonschema"; exit 1; }
|
||||
komorebic application-specific-configuration-schema | diff -u ${./schema.asc.json} - \
|
||||
|| { echo "schema.asc.json is stale: run just jsonschema"; exit 1; }
|
||||
expected=$(sha256sum ${./schema.json} | cut -d' ' -f1)
|
||||
head -n 1 ${./nix/komorebi-options.nix} | grep -qx "# schema-sha256: $expected" \
|
||||
|| { echo "nix/komorebi-options.nix is stale: run just nixgen"; exit 1; }
|
||||
touch $out
|
||||
'';
|
||||
|
||||
# the options the module is typed with, evaluated against the example configuration
|
||||
nix-options-validation = import ./nix/tests/default.nix { inherit pkgs; };
|
||||
|
||||
# every file of the key binding corpus through `komorebic hotkeys compile`, as the
|
||||
# module runs it
|
||||
keybindings-fixtures = import ./nix/tests/keybindings.nix {
|
||||
inherit pkgs;
|
||||
komorebic = build.fullBuild;
|
||||
};
|
||||
|
||||
# The NixOS module in real NixOS systems, evaluated and never built, so a Mac checks it
|
||||
# too. A VM suite, `vm-module`, runs it.
|
||||
nixos-module-eval = import ./nix/tests/nixos-module.nix {
|
||||
inherit pkgs;
|
||||
inherit (nixpkgs.lib) nixosSystem;
|
||||
module = self.nixosModules.default;
|
||||
komorebiFor = guestSystem: self.packages.${guestSystem}.komorebi-full;
|
||||
borderEffectFor = guestSystem: self.packages.${guestSystem}.kde-rounded-corners-komorebi;
|
||||
animationEffectFor = guestSystem: self.packages.${guestSystem}.kwin-effect-geometry-change-komorebi;
|
||||
};
|
||||
|
||||
# The Plasma guests to develop against, evaluated and never built, so that every system
|
||||
# sees an option that nixpkgs renamed or an assertion that fails. The QEMU guests are
|
||||
# systems in a VM (`vmVariant`), with a runner for the machine that runs QEMU; UTM's is
|
||||
# a system of its own. Each guest is for one kind of machine, which is also checked: the
|
||||
# architecture of the guest, the machine that runs its QEMU, and that a guest of a Linux
|
||||
# machine has KVM and one display device only.
|
||||
plasma-guests-eval =
|
||||
let
|
||||
guests = self.nixosConfigurations;
|
||||
machines =
|
||||
let
|
||||
mac = {
|
||||
guest = "aarch64-linux";
|
||||
host = "aarch64-darwin";
|
||||
};
|
||||
linux = system: {
|
||||
guest = system;
|
||||
host = system;
|
||||
};
|
||||
# the runner of the demo is given its display device, its ports and whether to
|
||||
# insist on KVM when it starts, by `run-kde`
|
||||
demo = machine: machine // { demo = true; };
|
||||
in
|
||||
{
|
||||
plasma-vm = mac;
|
||||
plasma-vm-session = mac;
|
||||
plasma-vm-x86_64 = linux "x86_64-linux";
|
||||
plasma-vm-session-x86_64 = linux "x86_64-linux";
|
||||
plasma-vm-aarch64 = linux "aarch64-linux";
|
||||
plasma-vm-session-aarch64 = linux "aarch64-linux";
|
||||
run-kde-x86_64 = demo (linux "x86_64-linux");
|
||||
run-kde-aarch64 = demo (linux "aarch64-linux");
|
||||
};
|
||||
isDisplay =
|
||||
option: lib.hasPrefix "-device virtio-vga" option || lib.hasPrefix "-device virtio-gpu" option;
|
||||
qemuGuest =
|
||||
name:
|
||||
let
|
||||
machine = machines.${name};
|
||||
demo = machine.demo or false;
|
||||
vm = guests.${name}.config.virtualisation.vmVariant.virtualisation;
|
||||
in
|
||||
assert lib.assertMsg (
|
||||
guests.${name}.pkgs.stdenv.hostPlatform.system == machine.guest
|
||||
) "${name} is not a ${machine.guest} guest";
|
||||
assert lib.assertMsg (
|
||||
vm.host.pkgs.stdenv.hostPlatform.system == machine.host
|
||||
) "${name} does not run on a ${machine.host} host";
|
||||
assert lib.assertMsg (
|
||||
vm.qemu.forceAccel != demo
|
||||
) "${name} would run without KVM or HVF, which is too slow to use";
|
||||
assert lib.assertMsg (
|
||||
builtins.length (builtins.filter isDisplay vm.qemu.options) == (if demo then 0 else 1)
|
||||
) "${name} does not have the display devices it should have";
|
||||
assert lib.assertMsg
|
||||
# an x86_64 machine has a VGA of its own, which would be a second display
|
||||
((machine.guest == "x86_64-linux" && !demo) == builtins.elem "-vga none" vm.qemu.options)
|
||||
"${name} has `-vga none` if and only if it is an x86_64 guest with a display device";
|
||||
assert lib.assertMsg (
|
||||
demo -> (vm.forwardPorts == [ ] && vm.sharedDirectories.run-kde.target == "/run/run-kde")
|
||||
) "${name} does not leave its ports and its shared directory to the runner's environment";
|
||||
{
|
||||
${name} = guests.${name}.config.virtualisation.vmVariant.system.build.toplevel;
|
||||
"${name}, its runner" = guests.${name}.config.system.build.vm;
|
||||
};
|
||||
builds = lib.foldl' (builds: name: builds // qemuGuest name) { } (lib.attrNames machines) // {
|
||||
plasma-utm = guests.plasma-utm.config.system.build.toplevel;
|
||||
};
|
||||
lines = lib.mapAttrsToList (
|
||||
name: drv: "${name}: ${builtins.unsafeDiscardStringContext drv.drvPath}"
|
||||
) builds;
|
||||
in
|
||||
pkgs.runCommand "plasma-guests-eval" { } ''
|
||||
${lib.concatMapStringsSep "\n" (line: "echo ${lib.escapeShellArg line}") lines}
|
||||
touch $out
|
||||
'';
|
||||
}
|
||||
# The probe builds (shellcheck runs over the script and over the guest's init as it
|
||||
# does) and its dry run works without a machine to probe, so that it cannot rot between
|
||||
# the times somebody runs it.
|
||||
// lib.optionalAttrs isLinux {
|
||||
wsl2-probe = wsl2ProbeForChecks.probe;
|
||||
wsl2-probe-dry-run =
|
||||
pkgs.runCommand "wsl2-probe-dry-run" { nativeBuildInputs = [ wsl2ProbeForChecks.probe ]; }
|
||||
''
|
||||
wsl2-probe --dry-run --no-prompt --report report.txt > out.txt
|
||||
cat out.txt
|
||||
for probe in P0 P1 P2 P3 P4 P5 P6; do
|
||||
grep -q "^$probe " out.txt || { echo "no verdict line for $probe"; exit 1; }
|
||||
done
|
||||
grep -q "PASTE THIS" out.txt
|
||||
grep -q "would run" out.txt
|
||||
# the report file has what the screen has
|
||||
grep -q "PASTE THIS" report.txt
|
||||
# a mistake in the options is refused
|
||||
if wsl2-probe --nonsense 2> err.txt; then exit 1; fi
|
||||
grep -q "unknown option" err.txt
|
||||
touch $out
|
||||
'';
|
||||
}
|
||||
# `run-kde` is shellchecked when it is built, and its output is what a test says it is
|
||||
// lib.optionalAttrs isLinux (
|
||||
{
|
||||
run-kde = config.packages.run-kde;
|
||||
}
|
||||
// import ./nix/tests/run-kde.nix {
|
||||
inherit pkgs;
|
||||
runKde = config.packages.run-kde;
|
||||
}
|
||||
)
|
||||
# The VM tests need QEMU with KVM, so only Linux checks them. A Mac runs the same tests
|
||||
# through legacyPackages.<system>.vm, see docs/dev/vm-tests.md.
|
||||
// lib.optionalAttrs isLinux (
|
||||
lib.mapAttrs' (name: test: lib.nameValuePair "vm-${name}" test) vm.suites
|
||||
)
|
||||
# the KWin effects komorebi drives, installed and inspected without a session
|
||||
// lib.optionalAttrs isLinux (
|
||||
import ./nix/tests/effects.nix {
|
||||
inherit pkgs;
|
||||
inherit (config) packages;
|
||||
}
|
||||
);
|
||||
|
||||
legacyPackages = {
|
||||
# every suite, as a test with a `driver`, on every system
|
||||
vm = vm.suites;
|
||||
# the suites of each tier, for the CI matrix
|
||||
vmTiers = vm.tiers;
|
||||
# the guests of every suite, to build on a Linux builder when the host is a Mac
|
||||
vmGuests = vm.guests;
|
||||
}
|
||||
// lib.optionalAttrs isLinux {
|
||||
# the same suites on a machine with no KVM, which is slow but works anywhere
|
||||
vmTcg =
|
||||
(import ./nix/tests/vm {
|
||||
hostPkgs = pkgs;
|
||||
inherit komorebiModule;
|
||||
scale = 8;
|
||||
}).suites;
|
||||
};
|
||||
|
||||
packages = lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
|
||||
inherit (build) komorebi komorebic;
|
||||
komorebi-full = build.fullBuild;
|
||||
default = build.fullBuild;
|
||||
kde-rounded-corners-komorebi = pkgs.callPackage ./nix/kde-rounded-corners.nix { };
|
||||
kwin-effect-geometry-change-komorebi = pkgs.callPackage ./nix/kwin-effect-geometry-change.nix { };
|
||||
wsl2-probe = wsl2Probe.probe;
|
||||
wsl2-probe-guest = wsl2Probe.guest;
|
||||
run-kde = runKde;
|
||||
};
|
||||
|
||||
apps = lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
|
||||
komorebi = {
|
||||
type = "app";
|
||||
program = "${build.komorebi}/bin/komorebi";
|
||||
meta.description = "The komorebi daemon";
|
||||
};
|
||||
komorebic = {
|
||||
type = "app";
|
||||
program = "${build.komorebic}/bin/komorebic";
|
||||
meta.description = "The command line interface of komorebi";
|
||||
};
|
||||
wsl2-probe = {
|
||||
type = "app";
|
||||
program = lib.getExe wsl2Probe.probe;
|
||||
meta.description = "Probes a NixOS-WSL2 machine for KVM, WSLg, a GPU and RDP";
|
||||
};
|
||||
run-kde = {
|
||||
type = "app";
|
||||
program = lib.getExe config.packages.run-kde;
|
||||
meta.description = "Start the komorebi demo in a virtual machine";
|
||||
};
|
||||
default = config.apps.komorebi;
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
name = "komorebi";
|
||||
|
||||
RUST_BACKTRACE = "full";
|
||||
|
||||
inputsFrom = [ build.fullBuild ];
|
||||
|
||||
packages = [
|
||||
rustToolchainWithNightlyRustfmt
|
||||
cargo-udeps
|
||||
|
||||
pkgs.cargo-deny
|
||||
pkgs.cargo-nextest
|
||||
pkgs.check-jsonschema
|
||||
pkgs.jq
|
||||
pkgs.just
|
||||
pkgs.ripgrep
|
||||
|
||||
# the tests of the sleep and lock signals start private buses (`kwin::power`)
|
||||
pkgs.dbus
|
||||
|
||||
# the bridge's type check and tests (`just check-js`)
|
||||
pkgs.nodejs
|
||||
pkgs.typescript
|
||||
|
||||
# the VM test library
|
||||
pkgs.ruff
|
||||
pkgs.ty
|
||||
(pkgs.python3.withPackages (ps: [ ps.pytest ]))
|
||||
];
|
||||
};
|
||||
|
||||
pre-commit = {
|
||||
check.enable = true;
|
||||
settings.hooks.treefmt = {
|
||||
enable = true;
|
||||
package = config.treefmt.build.wrapper;
|
||||
pass_filenames = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
flake = {
|
||||
overlays.default =
|
||||
final: _:
|
||||
let
|
||||
build = mkKomorebiPackages { pkgs = mkPkgs final.stdenv.hostPlatform.system; };
|
||||
in
|
||||
{
|
||||
inherit (build) komorebi komorebic;
|
||||
komorebi-full = build.fullBuild;
|
||||
# with the consumer's KWin, so that the plugin links the libkwin it is loaded into
|
||||
kde-rounded-corners-komorebi = final.callPackage ./nix/kde-rounded-corners.nix { };
|
||||
kwin-effect-geometry-change-komorebi = final.callPackage ./nix/kwin-effect-geometry-change.nix { };
|
||||
};
|
||||
overlays.komorebi = self.overlays.default;
|
||||
# the same packages built with the constant commit of the checks, for the VM tests
|
||||
overlays.forVmTests =
|
||||
final: prev:
|
||||
let
|
||||
build = mkKomorebiPackages { pkgs = mkPkgs final.stdenv.hostPlatform.system; };
|
||||
in
|
||||
(self.overlays.default final prev)
|
||||
// {
|
||||
komorebi = build.komorebiForVm;
|
||||
komorebic = build.komorebicForVm;
|
||||
komorebi-full = build.vmBuild;
|
||||
};
|
||||
|
||||
# `services.komorebi`, with the overlay that provides its package, so that a NixOS
|
||||
# configuration needs this flake as an input and one module line (docs/installation.md)
|
||||
nixosModules.default = {
|
||||
imports = [ ./nix/nixos-module.nix ];
|
||||
nixpkgs.overlays = [ self.overlays.default ];
|
||||
};
|
||||
nixosModules.komorebi = self.nixosModules.default;
|
||||
# `services.komorebi` with the packages the VM tests install
|
||||
nixosModules.forVmTests = {
|
||||
imports = [ ./nix/nixos-module.nix ];
|
||||
nixpkgs.overlays = [ self.overlays.forVmTests ];
|
||||
};
|
||||
|
||||
# Plasma guests to develop against (docs/dev/utm.md). For an Apple silicon Mac, QEMU runs
|
||||
# the first two under HVF, and UTM boots the third from a disk image. For a Linux machine
|
||||
# with KVM, QEMU runs the other four: the same two guests for an x86_64 host and for an
|
||||
# aarch64 one, each of which runs the guest of its own architecture. The last two are the
|
||||
# demo that `run-kde` starts.
|
||||
nixosConfigurations =
|
||||
let
|
||||
# `guest` is the system of the guest, and `host` the pkgs of the machine that runs QEMU
|
||||
mkPlasmaGuest =
|
||||
{ guest, host }:
|
||||
modules:
|
||||
nixpkgs.lib.nixosSystem {
|
||||
specialArgs.hostPkgs = host;
|
||||
modules = [
|
||||
self.nixosModules.default
|
||||
{ nixpkgs.hostPlatform = guest; }
|
||||
]
|
||||
++ modules;
|
||||
};
|
||||
onMac = mkPlasmaGuest {
|
||||
guest = "aarch64-linux";
|
||||
host = nixpkgs.legacyPackages.aarch64-darwin;
|
||||
};
|
||||
onLinux =
|
||||
system:
|
||||
mkPlasmaGuest {
|
||||
guest = system;
|
||||
host = nixpkgs.legacyPackages.${system};
|
||||
};
|
||||
session = [
|
||||
./nix/dev/plasma-vm.nix
|
||||
{ komorebi.plasmaVm.session = true; }
|
||||
];
|
||||
# the session guest with the demo of `run-kde` (nix/dev/run-kde.nix) and no display
|
||||
# device, which the command gives it when it starts the guest
|
||||
demo = [
|
||||
./nix/dev/plasma-vm.nix
|
||||
{
|
||||
komorebi.plasmaVm = {
|
||||
session = true;
|
||||
display = false;
|
||||
};
|
||||
}
|
||||
./nix/dev/run-kde.nix
|
||||
({ lib, ... }: { networking.hostName = lib.mkOverride 40 "komorebi-demo"; })
|
||||
];
|
||||
in
|
||||
{
|
||||
plasma-vm = onMac [ ./nix/dev/plasma-vm.nix ];
|
||||
plasma-vm-session = onMac session;
|
||||
plasma-utm = onMac [ ./nix/dev/plasma-utm.nix ];
|
||||
|
||||
plasma-vm-x86_64 = onLinux "x86_64-linux" [ ./nix/dev/plasma-vm.nix ];
|
||||
plasma-vm-session-x86_64 = onLinux "x86_64-linux" session;
|
||||
plasma-vm-aarch64 = onLinux "aarch64-linux" [ ./nix/dev/plasma-vm.nix ];
|
||||
plasma-vm-session-aarch64 = onLinux "aarch64-linux" session;
|
||||
|
||||
run-kde-x86_64 = onLinux "x86_64-linux" demo;
|
||||
run-kde-aarch64 = onLinux "aarch64-linux" demo;
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
mkOutputs {
|
||||
inherit inputs self;
|
||||
repoRoot = ./.;
|
||||
platformDir = "";
|
||||
}
|
||||
// {
|
||||
lib.mkOutputs = mkOutputs;
|
||||
};
|
||||
}
|
||||
Generated
-179
@@ -1,179 +0,0 @@
|
||||
{
|
||||
"nodes": {
|
||||
"crane": {
|
||||
"locked": {
|
||||
"lastModified": 1767461147,
|
||||
"narHash": "sha256-TH/xTeq/RI+DOzo+c+4F431eVuBpYVwQwBxzURe7kcI=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "7d59256814085fd9666a2ae3e774dc5ee216b630",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1767039857,
|
||||
"narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=",
|
||||
"owner": "NixOS",
|
||||
"repo": "flake-compat",
|
||||
"rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1765835352,
|
||||
"narHash": "sha256-XswHlK/Qtjasvhd1nOa1e8MgZ8GS//jBoTqWtrS1Giw=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "a34fae9c08a15ad73f295041fec82323541400a9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"git-hooks-nix": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"gitignore": "gitignore",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1767281941,
|
||||
"narHash": "sha256-6MkqajPICgugsuZ92OMoQcgSHnD6sJHwk8AxvMcIgTE=",
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"rev": "f0927703b7b1c8d97511c4116eb9b4ec6645a0fa",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"gitignore": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"git-hooks-nix",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1709087332,
|
||||
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1767364772,
|
||||
"narHash": "sha256-fFUnEYMla8b7UKjijLnMe+oVFOz6HjijGGNS1l7dYaQ=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "16c7794d0a28b5a37904d55bcca36003b9109aaa",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"lastModified": 1765674936,
|
||||
"narHash": "sha256-k00uTP4JNfmejrCLJOwdObYC9jHRrr/5M/a/8L2EIdo=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "2075416fcb47225d9b68ac469a5c4801a9c4dd85",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"crane": "crane",
|
||||
"flake-parts": "flake-parts",
|
||||
"git-hooks-nix": "git-hooks-nix",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay",
|
||||
"treefmt-nix": "treefmt-nix"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1793174968,
|
||||
"narHash": "sha256-u5nUf4cewaT36iIzG1s/VECktqUMiZaGF5BsgervsvQ=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "19ecdd08213836b36c4296a3a4f4af5a3d5308db",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"treefmt-nix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1767468822,
|
||||
"narHash": "sha256-MpffQxHxmjVKMiQd0Tg2IM/bSjjdQAM+NDcX6yxj7rE=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "d56486eb9493ad9c4777c65932618e9c2d0468fc",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
@@ -1,426 +0,0 @@
|
||||
{
|
||||
description = "komorebi for Mac";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
crane.url = "github:ipetkov/crane";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
||||
treefmt-nix.url = "github:numtide/treefmt-nix";
|
||||
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
|
||||
git-hooks-nix.url = "github:cachix/git-hooks.nix";
|
||||
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, ... }:
|
||||
let
|
||||
mkOutputs =
|
||||
{
|
||||
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
|
||||
;
|
||||
rootCrates = [
|
||||
"crates"
|
||||
"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";
|
||||
|
||||
# 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
|
||||
real = 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;
|
||||
# the unified komorebic package: its manifest, build script, main and the macOS module
|
||||
komorebic =
|
||||
builtins.elem relative [
|
||||
"komorebic"
|
||||
"komorebic/Cargo.toml"
|
||||
"komorebic/build.rs"
|
||||
"komorebic/src"
|
||||
"komorebic/src/main.rs"
|
||||
]
|
||||
|| pkgs.lib.hasPrefix "komorebic/src/macos" relative;
|
||||
|
||||
# the unified komorebi-client package: its manifest, lib.rs and the module of this platform
|
||||
komorebiClient =
|
||||
builtins.elem relative [
|
||||
"komorebi-client"
|
||||
"komorebi-client/Cargo.toml"
|
||||
"komorebi-client/src"
|
||||
"komorebi-client/src/lib.rs"
|
||||
"komorebi-client/src/macos.rs"
|
||||
"komorebi-client/tests"
|
||||
];
|
||||
|
||||
# the unified komorebi-bar package: its manifest, main.rs and the macOS module
|
||||
komorebiBar =
|
||||
builtins.elem relative [
|
||||
"komorebi-bar"
|
||||
"komorebi-bar/Cargo.toml"
|
||||
"komorebi-bar/src"
|
||||
"komorebi-bar/src/main.rs"
|
||||
]
|
||||
|| pkgs.lib.hasPrefix "komorebi-bar/src/macos" relative;
|
||||
|
||||
# the one komorebi binary package: its manifest, main.rs and tests
|
||||
komorebiDaemon =
|
||||
builtins.elem relative [
|
||||
"komorebi-daemon"
|
||||
"komorebi-daemon/Cargo.toml"
|
||||
"komorebi-daemon/src"
|
||||
"komorebi-daemon/src/main.rs"
|
||||
"komorebi-daemon/tests"
|
||||
];
|
||||
in
|
||||
((rootCrate || komorebic || komorebiClient || komorebiBar || komorebiDaemon) && !(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/src/macos/applications.json" path)
|
||||
# include_str! by the tests of the macOS daemon
|
||||
|| (builtins.match ".*/komorebic/fixtures/.*" path != null)
|
||||
);
|
||||
};
|
||||
|
||||
# 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
|
||||
|| member == "komorebic"
|
||||
|| member == "komorebi-client"
|
||||
|| member == "komorebi-daemon"
|
||||
|| member == "komorebi-bar"
|
||||
|| builtins.any (crate: member == crate || pkgs.lib.hasPrefix "${crate}/" member) rootCrates;
|
||||
};
|
||||
lockFile = builtins.path {
|
||||
path = repoRoot + "/Cargo.lock";
|
||||
name = "Cargo.lock";
|
||||
};
|
||||
tomlFile = builtins.path {
|
||||
path = repoRoot + "/Cargo.toml";
|
||||
name = "Cargo.toml";
|
||||
};
|
||||
packages = "-p komorebi -p komorebi-macos -p komorebic -p komorebi-client -p komorebi-bar";
|
||||
workspaceArgs = {
|
||||
pname = "komorebi-workspace";
|
||||
inherit version;
|
||||
# the lock and the root manifest as files of their own: a path inside the filtered source
|
||||
# would put all of it into the context of every derivation, and an edit of any file
|
||||
# would then change the dependencies
|
||||
cargoLock = lockFile;
|
||||
cargoToml = tomlFile;
|
||||
cargoVendorDir = craneLib.vendorCargoDeps { cargoLock = lockFile; };
|
||||
};
|
||||
|
||||
commonArgs = workspaceArgs // {
|
||||
cargoExtraArgs = "--locked ${packages}";
|
||||
inherit src version;
|
||||
strictDeps = true;
|
||||
# a constant, so that the dependencies and every check are the same derivations for
|
||||
# every commit; only fullBuild stamps the real one
|
||||
COMMIT_HASH = "nix-check";
|
||||
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";
|
||||
COMMIT_HASH = self.rev or (pkgs.lib.removeSuffix "-dirty" (self.dirtyRev or "unknown"));
|
||||
}
|
||||
);
|
||||
|
||||
extractBinary =
|
||||
binaryName:
|
||||
pkgs.runCommand "komorebi-${binaryName}"
|
||||
{
|
||||
meta = fullBuild.meta // { };
|
||||
}
|
||||
''
|
||||
mkdir -p $out/bin
|
||||
cp ${fullBuild}/bin/${binaryName} $out/bin/
|
||||
'';
|
||||
in
|
||||
{
|
||||
inherit
|
||||
craneLib
|
||||
src
|
||||
real
|
||||
workspaceArgs
|
||||
packages
|
||||
individualCrateArgs
|
||||
fullBuild
|
||||
;
|
||||
komorebi = extractBinary "komorebi";
|
||||
komorebic = extractBinary "komorebic";
|
||||
komorebi-bar = extractBinary "komorebi-bar";
|
||||
};
|
||||
|
||||
mkPkgs =
|
||||
system:
|
||||
import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ (import rust-overlay) ];
|
||||
};
|
||||
in
|
||||
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;
|
||||
|
||||
# rustfmt over the macOS files only, with the nightly rustfmt this tree's rustfmt.toml
|
||||
# needs and the 2024 edition of the manifests. `cargo fmt` would follow the `mod windows;`
|
||||
# of the shared entry files (komorebi-bar, komorebi-client), which the macOS source does
|
||||
# not have. The entry files of the shared crates are not checked; their macos modules are.
|
||||
komorebi-workspace-fmt =
|
||||
pkgs.runCommand "komorebi-workspace-fmt"
|
||||
{
|
||||
nativeBuildInputs = [ nightlyRustfmt ];
|
||||
src = build.real;
|
||||
}
|
||||
''
|
||||
cd $src
|
||||
files=$( { find komorebi-for-mac -name '*.rs'; \
|
||||
find komorebic/src/macos komorebi-bar/src/macos -name '*.rs'; \
|
||||
echo komorebi-client/src/macos.rs; } )
|
||||
rustfmt --edition 2024 --config-path komorebi-for-mac/rustfmt.toml --check $files
|
||||
touch $out
|
||||
'';
|
||||
|
||||
komorebi-workspace-toml-fmt = build.craneLib.taploFmt (
|
||||
build.workspaceArgs
|
||||
// {
|
||||
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;
|
||||
cargoDenyExtraArgs =
|
||||
"--workspace "
|
||||
+ pkgs.lib.concatMapStringsSep " " (p: "--exclude ${p}") [
|
||||
"komorebi-windows"
|
||||
"komorebi-gui"
|
||||
"komorebic-no-console"
|
||||
"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;
|
||||
|
||||
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;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user