Skip to content

Commit 7da962d

Browse files
committedSep 22, 2019
nixos/stage-1: add default link units to initrd
Also all udev rules.
1 parent c210392 commit 7da962d

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed
 

‎nixos/modules/system/boot/stage-1-init.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ done
204204
# Create device nodes in /dev.
205205
@preDeviceCommands@
206206
echo "running udev..."
207+
mkdir -p /etc/systemd
208+
ln -sfn @linkUnits@ /etc/systemd/network
207209
mkdir -p /etc/udev
208210
ln -sfn @udevRules@ /etc/udev/rules.d
209211
mkdir -p /dev/.mdadm
@@ -260,7 +262,7 @@ checkFS() {
260262
return 0
261263
fi
262264

263-
# Device might be already mounted manually
265+
# Device might be already mounted manually
264266
# e.g. NBD-device or the host filesystem of the file which contains encrypted root fs
265267
if mount | grep -q "^$device on "; then
266268
echo "skip checking already mounted $device"
@@ -343,7 +345,7 @@ mountFS() {
343345
elif [ "$fsType" = f2fs ]; then
344346
echo "resizing $device..."
345347
fsck.f2fs -fp "$device"
346-
resize.f2fs "$device"
348+
resize.f2fs "$device"
347349
fi
348350
;;
349351
esac

‎nixos/modules/system/boot/stage-1.nix

+12-5
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ let
120120
121121
# Copy udev.
122122
copy_bin_and_libs ${udev}/lib/systemd/systemd-udevd
123+
copy_bin_and_libs ${udev}/lib/systemd/systemd-sysctl
123124
copy_bin_and_libs ${udev}/bin/udevadm
124125
for BIN in ${udev}/lib/udev/*_id; do
125126
copy_bin_and_libs $BIN
@@ -198,6 +199,14 @@ let
198199
''; # */
199200

200201

202+
linkUnits = pkgs.runCommand "link-units" {
203+
allowedReferences = [ extraUtils ];
204+
preferLocalBuild = true;
205+
} ''
206+
mkdir -p $out
207+
cp -v ${udev}/lib/systemd/network/*.link $out/
208+
'';
209+
201210
udevRules = pkgs.runCommand "udev-rules" {
202211
allowedReferences = [ extraUtils ];
203212
preferLocalBuild = true;
@@ -206,9 +215,7 @@ let
206215
207216
echo 'ENV{LD_LIBRARY_PATH}="${extraUtils}/lib"' > $out/00-env.rules
208217
209-
cp -v ${udev}/lib/udev/rules.d/60-cdrom_id.rules $out/
210-
cp -v ${udev}/lib/udev/rules.d/60-persistent-storage.rules $out/
211-
cp -v ${udev}/lib/udev/rules.d/80-drivers.rules $out/
218+
cp -v ${udev}/lib/udev/rules.d/*.rules $out/
212219
cp -v ${pkgs.lvm2}/lib/udev/rules.d/*.rules $out/
213220
${config.boot.initrd.extraUdevRulesCommands}
214221
@@ -222,7 +229,7 @@ let
222229
--replace ${pkgs.lvm2}/sbin ${extraUtils}/bin \
223230
--replace ${pkgs.mdadm}/sbin ${extraUtils}/sbin \
224231
--replace ${pkgs.bash}/bin/sh ${extraUtils}/bin/sh \
225-
--replace ${udev}/bin/udevadm ${extraUtils}/bin/udevadm
232+
--replace ${udev} ${extraUtils}
226233
done
227234
228235
# Work around a bug in QEMU, which doesn't implement the "READ
@@ -257,7 +264,7 @@ let
257264
${pkgs.buildPackages.busybox}/bin/ash -n $target
258265
'';
259266

260-
inherit udevRules extraUtils modulesClosure;
267+
inherit linkUnits udevRules extraUtils modulesClosure;
261268

262269
inherit (config.boot) resumeDevice;
263270

0 commit comments

Comments
 (0)
Please sign in to comment.