From 2de742155a930e7949259a49113207c92597976b Mon Sep 17 00:00:00 2001 From: Sergei Zimmerman Date: Tue, 18 Nov 2025 23:58:50 +0300 Subject: [PATCH] packaging: Unbork win shells with unavailable dependencies Makes the cross-x86_64-w64-mingw32 devshell slightly less broken. It still needs a bit of massaging to function, but that's much less cumbersome now that the generic machinery with genericClosure that evaluates drvPath doesn't barf on unavailable packages. --- packaging/dev-shell.nix | 36 +++++++++++++++------------- src/kaitai-struct-checks/package.nix | 2 +- src/perl/package.nix | 4 ++++ 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/packaging/dev-shell.nix b/packaging/dev-shell.nix index 2174b4edb..95cbc4a36 100644 --- a/packaging/dev-shell.nix +++ b/packaging/dev-shell.nix @@ -130,15 +130,19 @@ pkgs.nixComponents2.nix-util.overrideAttrs ( havePerl = stdenv.buildPlatform == stdenv.hostPlatform && stdenv.hostPlatform.isUnix; ignoreCrossFile = flags: builtins.filter (flag: !(lib.strings.hasInfix "cross-file" flag)) flags; + availableComponents = lib.filterAttrs ( + k: v: lib.meta.availableOn pkgs.hostPlatform v + ) allComponents; + activeComponents = buildInputsClosureCond isInternal ( - lib.attrValues (finalAttrs.passthru.config.getComponents allComponents) + lib.attrValues (finalAttrs.passthru.config.getComponents availableComponents) ); allComponents = lib.filterAttrs (k: v: lib.isDerivation v) pkgs.nixComponents2; internalDrvs = byDrvPath ( # Drop the attr names (not present in buildInputs anyway) - lib.attrValues allComponents - ++ lib.concatMap (c: lib.attrValues c.tests or { }) (lib.attrValues allComponents) + lib.attrValues availableComponents + ++ lib.concatMap (c: lib.attrValues c.tests or { }) (lib.attrValues availableComponents) ); isInternal = @@ -187,19 +191,19 @@ pkgs.nixComponents2.nix-util.overrideAttrs ( ); small = - (finalAttrs.finalPackage.withActiveComponents (c: { - inherit (c) - nix-cli - nix-util-tests - nix-store-tests - nix-expr-tests - nix-fetchers-tests - nix-flake-tests - nix-functional-tests - # Currently required - nix-perl-bindings - ; - })).overrideAttrs + (finalAttrs.finalPackage.withActiveComponents ( + c: + lib.intersectAttrs (lib.genAttrs [ + "nix-cli" + "nix-util-tests" + "nix-store-tests" + "nix-expr-tests" + "nix-fetchers-tests" + "nix-flake-tests" + "nix-functional-tests" + "nix-perl-bindings" + ] (_: null)) c + )).overrideAttrs (o: { mesonFlags = o.mesonFlags ++ [ # TODO: infer from activeComponents or vice versa diff --git a/src/kaitai-struct-checks/package.nix b/src/kaitai-struct-checks/package.nix index a466441d3..4257ceb76 100644 --- a/src/kaitai-struct-checks/package.nix +++ b/src/kaitai-struct-checks/package.nix @@ -65,6 +65,6 @@ mkMesonDerivation (finalAttrs: { ''; meta = { - platforms = lib.platforms.all; + platforms = lib.platforms.unix; }; }) diff --git a/src/perl/package.nix b/src/perl/package.nix index 96a41ae47..864558ec8 100644 --- a/src/perl/package.nix +++ b/src/perl/package.nix @@ -74,5 +74,9 @@ perl.pkgs.toPerlModule ( ]; strictDeps = false; + + meta = { + platforms = lib.platforms.unix; + }; }) )