cross: add a cantBinfmt option to force a package to be built on a non-binfmt machine

This commit is contained in:
Colin 2023-12-06 19:20:39 +00:00
parent ac3b0b873b
commit 801da9d321
3 changed files with 12 additions and 2 deletions

View File

@ -1,4 +1,4 @@
{ lib, pkgs, ... }: { config, lib, pkgs, ... }:
{ {
imports = [ imports = [
@ -68,6 +68,11 @@
HandlePowerKey=ignore HandlePowerKey=ignore
''; '';
# some packages build only if binfmt *isn't* present
nix.settings.system-features = lib.mkIf (config.boot.binfmt.emulatedSystems == []) [
"no-binfmt"
];
# services.snapper.configs = { # services.snapper.configs = {
# root = { # root = {
# subvolume = "/"; # subvolume = "/";

View File

@ -94,6 +94,7 @@ in
speedFactor = 2; speedFactor = 2;
supportedFeatures = [ supportedFeatures = [
# "big-parallel" # it can't reliably build webkitgtk # "big-parallel" # it can't reliably build webkitgtk
"no-binfmt"
]; ];
mandatoryFeatures = [ ]; mandatoryFeatures = [ ];
sshUser = "nixremote"; sshUser = "nixremote";

View File

@ -60,7 +60,8 @@ let
pkg pkg
); );
needsBinfmt = pkg: pkg.overrideAttrs (upstream: { needsBinfmt = pkg: (pkg.overrideAttrs or (updater: pkg // (updater pkg))) (upstream: {
# weird signature to support passing *either* a package, or an ordinary attrset
# "kvm" isn't precisely the right feature here. # "kvm" isn't precisely the right feature here.
# but the effect is that if you build a `needsBinfmt` package with `-j0`, # but the effect is that if you build a `needsBinfmt` package with `-j0`,
# then nix will try to find a builder that's been marked with `kvm` feature, # then nix will try to find a builder that's been marked with `kvm` feature,
@ -68,6 +69,9 @@ let
# be built on a binfmt-enabled builder (or not built, if no binfmt builders). # be built on a binfmt-enabled builder (or not built, if no binfmt builders).
requiredSystemFeatures = (upstream.requiredSystemFeatures or []) ++ [ "kvm" ]; requiredSystemFeatures = (upstream.requiredSystemFeatures or []) ++ [ "kvm" ];
}); });
cantBinfmt = pkg: (pkg.overrideAttrs or (updater: pkg // (updater pkg))) (upstream: {
requiredSystemFeatures = (upstream.requiredSystemFeatures or []) ++ [ "no-binfmt" ];
});
# such packages could build with `needsBinfmt` *or* `buildInQemu`. # such packages could build with `needsBinfmt` *or* `buildInQemu`.
# - the former is [an order of magnitude] faster, but the latter gets me closer to a pure installation. # - the former is [an order of magnitude] faster, but the latter gets me closer to a pure installation.