Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
nixos/stage-1: add default link units to initrd
Also all udev rules.
  • Loading branch information
fpletz committed Sep 22, 2019
1 parent c210392 commit 7da962d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
6 changes: 4 additions & 2 deletions nixos/modules/system/boot/stage-1-init.sh
Expand Up @@ -204,6 +204,8 @@ done
# Create device nodes in /dev.
@preDeviceCommands@
echo "running udev..."
mkdir -p /etc/systemd
ln -sfn @linkUnits@ /etc/systemd/network
mkdir -p /etc/udev
ln -sfn @udevRules@ /etc/udev/rules.d
mkdir -p /dev/.mdadm
Expand Down Expand Up @@ -260,7 +262,7 @@ checkFS() {
return 0
fi

# Device might be already mounted manually
# Device might be already mounted manually
# e.g. NBD-device or the host filesystem of the file which contains encrypted root fs
if mount | grep -q "^$device on "; then
echo "skip checking already mounted $device"
Expand Down Expand Up @@ -343,7 +345,7 @@ mountFS() {
elif [ "$fsType" = f2fs ]; then
echo "resizing $device..."
fsck.f2fs -fp "$device"
resize.f2fs "$device"
resize.f2fs "$device"
fi
;;
esac
Expand Down
17 changes: 12 additions & 5 deletions nixos/modules/system/boot/stage-1.nix
Expand Up @@ -120,6 +120,7 @@ let
# Copy udev.
copy_bin_and_libs ${udev}/lib/systemd/systemd-udevd
copy_bin_and_libs ${udev}/lib/systemd/systemd-sysctl
copy_bin_and_libs ${udev}/bin/udevadm
for BIN in ${udev}/lib/udev/*_id; do
copy_bin_and_libs $BIN
Expand Down Expand Up @@ -198,6 +199,14 @@ let
''; # */


linkUnits = pkgs.runCommand "link-units" {
allowedReferences = [ extraUtils ];
preferLocalBuild = true;
} ''
mkdir -p $out
cp -v ${udev}/lib/systemd/network/*.link $out/
'';

udevRules = pkgs.runCommand "udev-rules" {
allowedReferences = [ extraUtils ];
preferLocalBuild = true;
Expand All @@ -206,9 +215,7 @@ let
echo 'ENV{LD_LIBRARY_PATH}="${extraUtils}/lib"' > $out/00-env.rules
cp -v ${udev}/lib/udev/rules.d/60-cdrom_id.rules $out/
cp -v ${udev}/lib/udev/rules.d/60-persistent-storage.rules $out/
cp -v ${udev}/lib/udev/rules.d/80-drivers.rules $out/
cp -v ${udev}/lib/udev/rules.d/*.rules $out/
cp -v ${pkgs.lvm2}/lib/udev/rules.d/*.rules $out/
${config.boot.initrd.extraUdevRulesCommands}
Expand All @@ -222,7 +229,7 @@ let
--replace ${pkgs.lvm2}/sbin ${extraUtils}/bin \
--replace ${pkgs.mdadm}/sbin ${extraUtils}/sbin \
--replace ${pkgs.bash}/bin/sh ${extraUtils}/bin/sh \
--replace ${udev}/bin/udevadm ${extraUtils}/bin/udevadm
--replace ${udev} ${extraUtils}
done
# Work around a bug in QEMU, which doesn't implement the "READ
Expand Down Expand Up @@ -257,7 +264,7 @@ let
${pkgs.buildPackages.busybox}/bin/ash -n $target
'';

inherit udevRules extraUtils modulesClosure;
inherit linkUnits udevRules extraUtils modulesClosure;

inherit (config.boot) resumeDevice;

Expand Down

0 comments on commit 7da962d

Please sign in to comment.