nixos-init: handle kernels without module support (#447005)

Changed files
+16 -9
pkgs
by-name
ni
nixos-init
+16 -9
pkgs/by-name/ni/nixos-init/src/activate.rs
···
// a procfs in a chroot would.
const MODPROBE_PATH: &str = "/proc/sys/kernel/modprobe";
-
fs::write(
-
MODPROBE_PATH,
-
modprobe_binary.as_ref().as_os_str().as_encoded_bytes(),
-
)
-
.with_context(|| {
-
format!(
-
"Failed to populate modprobe path with {}",
-
modprobe_binary.as_ref().display()
+
if Path::new(MODPROBE_PATH).exists() {
+
fs::write(
+
MODPROBE_PATH,
+
modprobe_binary.as_ref().as_os_str().as_encoded_bytes(),
)
-
})?;
+
.with_context(|| {
+
format!(
+
"Failed to populate modprobe path with {}",
+
modprobe_binary.as_ref().display()
+
)
+
})?;
+
} else {
+
log::info!("{MODPROBE_PATH} doesn't exist. Not populating it...");
+
}
+
Ok(())
}
···
firmware.as_ref().display()
)
})?;
+
} else {
+
log::info!("{FIRMWARE_SERCH_PATH} doesn't exist. Not populating it...");
}
Ok(())