From bd43222c45c61c8fa3fdc7acc5dc6cf07ae91823 Mon Sep 17 00:00:00 2001 From: Francesco Zanini Date: Sun, 8 Jun 2025 09:42:03 +0200 Subject: [PATCH] Allow disabling copying of udev rules Currently, the builder builds the whole `system.build.etc`, which is a rather enormous closure in some configurations. Also, it requires the build of all packages declared in `systemPackages` for the build architecture, which is in many cases unneeded, and can fail if the packages are platform-specific. --- lib/make-disk-image.nix | 4 +++- module.nix | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/make-disk-image.nix b/lib/make-disk-image.nix index ec0b32eb..de864851 100644 --- a/lib/make-disk-image.nix +++ b/lib/make-disk-image.nix @@ -121,7 +121,9 @@ let ln -sfn /proc/self/fd/2 /dev/stderr mkdir -p /etc/udev mount -t efivarfs none /sys/firmware/efi/efivars - ln -sfn ${systemToInstallNative.config.system.build.etc}/etc/udev/rules.d /etc/udev/rules.d + ${lib.optionalString cfg.useUdevRules '' + ln -sfn ${systemToInstallNative.config.system.build.etc}/etc/udev/rules.d /etc/udev/rules.d + ''} mkdir -p /dev/.mdadm ${pkgs.systemdMinimal}/lib/systemd/systemd-udevd --daemon partprobe diff --git a/module.nix b/module.nix index 24d2305a..30893685 100644 --- a/module.nix +++ b/module.nix @@ -121,6 +121,15 @@ in description = "QEMU image format to use for the disk images"; default = "raw"; }; + + useUdevRules = lib.mkOption { + type = lib.types.bool; + default = true; + description = '' + Copy the udev rules in the VM while building. It can be disabled when unnecessary to speed-up the build, + and e.g. when cross-building incompatible packages. + ''; + }; }; memSize = lib.mkOption {