Merge pull request #262179 from ElvishJerricco/systemd-stage-1-specific-fs-packages

systemd-stage-1: Use specific fs packages
This commit is contained in:
nikstur 2023-10-21 13:25:42 +02:00 committed by GitHub
commit 6958acea7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 28 additions and 10 deletions

View File

@ -358,7 +358,7 @@ in {
++ lib.optional (cfg.enableTpm2 && !(pkgs.stdenv.hostPlatform.isRiscV64 || pkgs.stdenv.hostPlatform.isArmv7)) "tpm-crb";
boot.initrd.systemd = {
initrdBin = [pkgs.bash pkgs.coreutils cfg.package.kmod cfg.package] ++ config.system.fsPackages;
initrdBin = [pkgs.bash pkgs.coreutils cfg.package.kmod cfg.package];
extraBin = {
less = "${pkgs.less}/bin/less";
mount = "${cfg.package.util-linux}/bin/mount";

View File

@ -52,34 +52,37 @@ in
config = mkMerge [
(mkIf enableBtrfs {
system.fsPackages = [ pkgs.btrfs-progs ];
})
boot.initrd.kernelModules = mkIf inInitrd [ "btrfs" ];
boot.initrd.availableKernelModules = mkIf inInitrd (
(mkIf inInitrd {
boot.initrd.kernelModules = [ "btrfs" ];
boot.initrd.availableKernelModules =
[ "crc32c" ]
++ optionals (config.boot.kernelPackages.kernel.kernelAtLeast "5.5") [
# Needed for mounting filesystems with new checksums
"xxhash_generic"
"blake2b_generic"
"sha256_generic" # Should be baked into our kernel, just to be sure
]
);
];
boot.initrd.extraUtilsCommands = mkIf (inInitrd && !config.boot.initrd.systemd.enable)
boot.initrd.extraUtilsCommands = mkIf (!config.boot.initrd.systemd.enable)
''
copy_bin_and_libs ${pkgs.btrfs-progs}/bin/btrfs
ln -sv btrfs $out/bin/btrfsck
ln -sv btrfsck $out/bin/fsck.btrfs
'';
boot.initrd.extraUtilsCommandsTest = mkIf (inInitrd && !config.boot.initrd.systemd.enable)
boot.initrd.extraUtilsCommandsTest = mkIf (!config.boot.initrd.systemd.enable)
''
$out/bin/btrfs --version
'';
boot.initrd.postDeviceCommands = mkIf (inInitrd && !config.boot.initrd.systemd.enable)
boot.initrd.postDeviceCommands = mkIf (!config.boot.initrd.systemd.enable)
''
btrfs device scan
'';
boot.initrd.systemd.initrdBin = [ pkgs.btrfs-progs ];
})
(mkIf enableAutoScrub {

View File

@ -21,5 +21,7 @@ in
copy_bin_and_libs ${pkgs.cifs-utils}/sbin/mount.cifs
'';
boot.initrd.systemd.extraBin."mount.cifs" = mkIf inInitrd "${pkgs.cifs-utils}/sbin/mount.cifs";
};
}

View File

@ -25,5 +25,7 @@ in
ln -sv e2fsck $out/bin/fsck.ext4
'';
boot.initrd.systemd.initrdBin = lib.mkIf inInitrd [ pkgs.e2fsprogs ];
};
}

View File

@ -16,5 +16,7 @@ in
boot.initrd.extraUtilsCommands = mkIf (inInitrd && !config.boot.initrd.systemd.enable) ''
copy_bin_and_libs ${pkgs.f2fs-tools}/sbin/fsck.f2fs
'';
boot.initrd.systemd.initrdBin = mkIf inInitrd [ pkgs.f2fs-tools ];
};
}

View File

@ -15,5 +15,7 @@ in
boot.initrd.extraUtilsCommands = mkIf (inInitrd && !config.boot.initrd.systemd.enable) ''
copy_bin_and_libs ${pkgs.jfsutils}/sbin/fsck.jfs
'';
boot.initrd.systemd.initrdBin = mkIf inInitrd [ pkgs.jfsutils ];
};
}

View File

@ -21,5 +21,7 @@ in
ln -s reiserfsck $out/bin/fsck.reiserfs
'';
boot.initrd.systemd.initrdBin = mkIf inInitrd [ pkgs.reiserfsprogs ];
};
}

View File

@ -21,5 +21,7 @@ in
ln -sv dosfsck $out/bin/fsck.vfat
'';
boot.initrd.systemd.extraBin = mkIf inInitrd [ pkgs.dosfstools ];
};
}

View File

@ -26,5 +26,7 @@ in
''
sed -i -e 's,^#!.*,#!'$out/bin/sh, $out/bin/fsck.xfs
'';
boot.initrd.systemd.initrdBin = mkIf inInitrd [ pkgs.xfsprogs.bin ];
};
}

View File

@ -632,7 +632,8 @@ in
targets.zfs-import.wantedBy = [ "zfs.target" ];
targets.zfs.wantedBy = [ "initrd.target" ];
extraBin = {
# zpool and zfs are already in thanks to fsPackages
zpool = "${cfgZfs.package}/sbin/zpool";
zfs = "${cfgZfs.package}/sbin/zfs";
awk = "${pkgs.gawk}/bin/awk";
};
};

View File

@ -195,7 +195,7 @@ fn handle_path(
.wrap_err_with(|| format!("failed to resolve symlink of {:?}", source))?;
// Create the link, then push its target to the queue
if !target.exists() {
if !target.exists() && !target.is_symlink() {
unix::fs::symlink(&link_target, &target).wrap_err_with(|| {
format!("failed to symlink {:?} to {:?}", link_target, target)
})?;