feat(windows): give mkLogosModule an x86_64-windows target

Routes every package-set construction in the builder through one helper,
common.mkPkgs, and teaches that helper the "x86_64-windows" pseudo-system.
This is the leverage point for the whole module ecosystem: modules do not
construct pkgs themselves, so fixing it here lets all ~40 of them target
Windows without each re-deriving the cross plumbing.

x86_64-windows cannot be produced by `import nixpkgs { system = ...; }` --
a cross derivation's `system` attribute is its BUILD platform, so it needs
localSystem/crossSystem plus the mingw overlays, which is exactly what
logos-nix.lib.mkWindowsPkgs wraps. logos-nix was already an input of this
flake but was never threaded into the lib; it now reaches common.nix via
lib/default.nix, and the pseudo-system is only advertised when it is
present, so a caller without it is unaffected.

Ten sites moved: common.nix, buildCppPlugin.nix x2, mkLogosQmlModule.nix
x2, mkLogosModuleTests.nix, mkLogosModule.nix x4. `systems` and
`forAllSystems` moved into the let block, since an attribute set is not
recursive and both now reference each other.

The Rust path keeps its rust-overlay via mkPkgsWith, which THROWS for a
Windows target rather than silently dropping the overlay and handing back a
package set that is not what the caller asked for. Rust modules on Windows
were already out of scope; this makes that explicit at eval time instead of
producing a subtly wrong build.

Verified: logos-capability-module evaluates unchanged on aarch64-darwin and
now also evaluates for x86_64-windows.
This commit is contained in:
Dario Gabriel Lipicar
2026-08-10 16:24:02 -03:00
parent 7fbb9420a3
commit 550c7c9c9f
7 changed files with 55 additions and 23 deletions
+2 -1
View File
@@ -48,7 +48,7 @@
nixpkgs.follows = "logos-nix/nixpkgs";
};
outputs = { self, nixpkgs, logos-cpp-sdk, logos-protocol, logos-qt-sdk, logos-module, logos-plugin-qt, logos-plugin-core, nix-bundle-logos-module-install, nix-bundle-lgx, logos-standalone-app, logos-test-framework, logos-rust-sdk, rust-overlay ? null, ... }:
outputs = { self, nixpkgs, logos-nix, logos-cpp-sdk, logos-protocol, logos-qt-sdk, logos-module, logos-plugin-qt, logos-plugin-core, nix-bundle-logos-module-install, nix-bundle-lgx, logos-standalone-app, logos-test-framework, logos-rust-sdk, rust-overlay ? null, ... }:
let
systems = [ "aarch64-darwin" "x86_64-darwin" "aarch64-linux" "x86_64-linux" ];
@@ -61,6 +61,7 @@
# Use rawLib from backends — we inject logos-cpp-sdk/logos-module ourselves
lib = import ./lib {
inherit nixpkgs nix-bundle-lgx nix-bundle-logos-module-install logos-standalone-app;
inherit logos-nix;
inherit logos-cpp-sdk logos-protocol logos-qt-sdk logos-module logos-test-framework logos-rust-sdk;
inherit rust-overlay;
inherit (nixpkgs) lib;
+2 -2
View File
@@ -39,7 +39,7 @@ let
# Per-system build outputs
perSystem = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
pkgs = common.mkPkgs system;
# ── Concrete dependency classification (mirrors mkLogosModule.nix) ──────
# LIDL-based deps → bindings generated from the dep's published `lidl`
@@ -252,7 +252,7 @@ let
# Development shell (delegates to backend for deps)
devShells = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
pkgs = common.mkPkgs system;
logosSdk = logos-cpp-sdk.packages.${system}.default;
logosQtSdk = logos-qt-sdk.packages.${system}.default;
# The Qt glue generator (universal/cdylib/ui backends) — Qt code is
+42 -11
View File
@@ -1,6 +1,6 @@
# Common utilities shared across all builder functions (backend-agnostic)
# Qt-specific build deps and cmake flags now live in the plugin backend.
{ lib, nix-bundle-lgx ? null }:
{ lib, nix-bundle-lgx ? null, nixpkgs ? null, logos-nix ? null }:
let
# Recursively collect all module dependencies (direct + transitive) from flake
@@ -51,19 +51,50 @@ let
# direct overrides transitive so the closest (most specific) dep wins
transitive // direct;
in {
inherit collectAllModuleDeps;
# Supported target systems. "x86_64-windows" is a PSEUDO-system: a cross
# derivation's `system` attribute is its BUILD platform, so this evaluates
# anywhere but only realises on x86_64-linux.
systems = [ "aarch64-darwin" "x86_64-darwin" "aarch64-linux" "x86_64-linux" ]
++ lib.optional (logos-nix != null) "x86_64-windows";
# Supported target systems
systems = [ "aarch64-darwin" "x86_64-darwin" "aarch64-linux" "x86_64-linux" ];
# THE package-set constructor. Every module's pkgs comes from here, which is
# what lets ~40 modules target Windows without each re-deriving the cross
# plumbing.
#
# x86_64-windows cannot be produced by `import nixpkgs { system = ...; }` --
# it needs localSystem/crossSystem plus logos-nix's mingw overlays, which is
# exactly what logos-nix.lib.mkWindowsPkgs wraps.
mkPkgsWith = extraOverlays: system:
if system != "x86_64-windows" then
import nixpkgs { inherit system; overlays = extraOverlays; }
else if logos-nix == null then
throw ("logos-module-builder: targeting x86_64-windows requires the "
+ "logos-nix input to be threaded into the builder lib.")
else if extraOverlays != [ ] then
# Rather than silently drop them and hand back a package set that is not
# what the caller asked for. mkWindowsPkgs owns its overlay list (the
# mingw cross fixes); teach it to merge before removing this.
throw ("logos-module-builder: overlays are not yet supported for the "
+ "x86_64-windows target (requested "
+ toString (builtins.length extraOverlays) + ").")
else
logos-nix.lib.mkWindowsPkgs { buildSystem = "x86_64-linux"; };
mkPkgs = mkPkgsWith [ ];
# Helper to run a function for all systems
forAllSystems = nixpkgs: f:
lib.genAttrs [ "aarch64-darwin" "x86_64-darwin" "aarch64-linux" "x86_64-linux" ]
(system: f {
inherit system;
pkgs = import nixpkgs { inherit system; };
});
forAllSystems = _nixpkgs: f:
lib.genAttrs systems (system: f {
inherit system;
pkgs = mkPkgs system;
});
in {
inherit systems mkPkgs mkPkgsWith forAllSystems;
inherit collectAllModuleDeps;
# Determine library extension based on platform
getLibExtension = pkgs:
+2 -2
View File
@@ -4,11 +4,11 @@
#
# logos-cpp-sdk and logos-module are owned by this builder and injected into
# backends — backends never resolve these deps themselves.
{ nixpkgs, lib, uiBackend, coreBackend, logos-cpp-sdk, logos-protocol ? null, logos-qt-sdk ? null, logos-module, logos-test-framework, logos-rust-sdk ? null, nix-bundle-lgx, nix-bundle-logos-module-install, logos-standalone-app, builderRoot, rust-overlay ? null }:
{ nixpkgs, lib, logos-nix ? null, uiBackend, coreBackend, logos-cpp-sdk, logos-protocol ? null, logos-qt-sdk ? null, logos-module, logos-test-framework, logos-rust-sdk ? null, nix-bundle-lgx, nix-bundle-logos-module-install, logos-standalone-app, builderRoot, rust-overlay ? null }:
let
# Import common utilities (backend-agnostic)
common = import ./common.nix { inherit lib nix-bundle-lgx; };
common = import ./common.nix { inherit lib nix-bundle-lgx nixpkgs logos-nix; };
# Import the metadata parser (reads metadata.json)
parseMetadata = import ./parseMetadata.nix { inherit lib; };
+4 -4
View File
@@ -90,7 +90,7 @@ let
# Package outputs
packages = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
pkgs = common.mkPkgs system;
# Rust toolchain for the crate compile. Default = the pinned nixpkgs rustc,
# so non-Rust modules and Rust modules without a `nix.rust.toolchain` are
@@ -102,7 +102,7 @@ let
if config.nix_rust.toolchain != null && rust-overlay != null
then
let
rpkgs = import nixpkgs { inherit system; overlays = [ (import rust-overlay) ]; };
rpkgs = common.mkPkgsWith [ (import rust-overlay) ] system;
toolchain = rpkgs.rust-bin.stable.${config.nix_rust.toolchain}.default;
in rpkgs.makeRustPlatform { cargo = toolchain; rustc = toolchain; }
else pkgs.rustPlatform;
@@ -645,7 +645,7 @@ let
# Development shell (delegates to backend for deps)
devShells = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
pkgs = common.mkPkgs system;
logosSdk = logos-cpp-sdk.packages.${system}.default;
logosQtSdk = logos-qt-sdk.packages.${system}.default;
# The Qt glue generator (universal/cdylib/ui backends) — Qt code is
@@ -738,7 +738,7 @@ let
else {
apps = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
pkgs = common.mkPkgs system;
# Collect all module dependencies (direct + transitive) for bundling
allDeps = common.collectAllModuleDeps system flakeInputs config.dependencies;
in {
+1 -1
View File
@@ -58,7 +58,7 @@ let
checks = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
pkgs = common.mkPkgs system;
logosSdk = logos-cpp-sdk.packages.${system}.default;
logosQtSdk = logos-qt-sdk.packages.${system}.default;
# The Qt glue generator (universal/cdylib/ui backends) — Qt code is
+2 -2
View File
@@ -76,7 +76,7 @@ let
pkgsFor = system:
if hasBackend
then built.perSystem.${system}.pkgs
else import nixpkgs { inherit system; };
else common.mkPkgs system;
# Helper: create a combined derivation from a plugin lib + QML view from source.
# Used for both default and portable variants. For QML-only modules, pluginLib is null.
@@ -231,7 +231,7 @@ let
apps = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
pkgs = common.mkPkgs system;
# Collect all module dependencies (direct + transitive) for bundling
allDeps = common.collectAllModuleDeps system flakeInputs config.dependencies;
in {