lol

nixos/filesystems: Make most simple filesystems compatible with systemd

This includes disabling some features in the initrd by default, this is
only done when the new initrd is used. Namely, ext and bcache are
disabled by default. bcache gets an own enable option while ext is
detected like any other filesystem.

+51 -24
+3 -3
nixos/modules/installer/cd-dvd/system-tarball-sheevaplug.nix
··· 87 87 boot.initrd.availableKernelModules = 88 88 [ "mvsdio" "reiserfs" "ext3" "ums-cypress" "rtc_mv" "ext4" ]; 89 89 90 - boot.postBootCommands = 90 + boot.postBootCommands = lib.mkIf (!boot.initrd.systemd.enable) 91 91 '' 92 92 mkdir -p /mnt 93 93 94 94 cp ${dummyConfiguration} /etc/nixos/configuration.nix 95 95 ''; 96 96 97 - boot.initrd.extraUtilsCommands = 97 + boot.initrd.extraUtilsCommands = lib.mkIf (!boot.initrd.systemd.enable) 98 98 '' 99 99 copy_bin_and_libs ${pkgs.util-linux}/sbin/hwclock 100 100 ''; 101 101 102 - boot.initrd.postDeviceCommands = 102 + boot.initrd.postDeviceCommands = lib.mkIf (!boot.initrd.systemd.enable) 103 103 '' 104 104 hwclock -s 105 105 '';
+16 -6
nixos/modules/tasks/bcache.nix
··· 1 - { pkgs, ... }: 1 + { config, lib, pkgs, ... }: 2 2 3 3 { 4 + options.boot.initrd.services.bcache.enable = (lib.mkEnableOption "bcache support in the initrd") // { 5 + visible = false; # only works with systemd stage 1 6 + }; 4 7 5 - environment.systemPackages = [ pkgs.bcache-tools ]; 8 + config = { 6 9 7 - services.udev.packages = [ pkgs.bcache-tools ]; 10 + environment.systemPackages = [ pkgs.bcache-tools ]; 8 11 9 - boot.initrd.extraUdevRulesCommands = '' 10 - cp -v ${pkgs.bcache-tools}/lib/udev/rules.d/*.rules $out/ 11 - ''; 12 + services.udev.packages = [ pkgs.bcache-tools ]; 13 + 14 + boot.initrd.extraUdevRulesCommands = lib.mkIf (!config.boot.initrd.systemd.enable) '' 15 + cp -v ${pkgs.bcache-tools}/lib/udev/rules.d/*.rules $out/ 16 + ''; 12 17 18 + boot.initrd.services.udev = lib.mkIf config.boot.initrd.services.bcache.enable { 19 + packages = [ pkgs.bcache-tools ]; 20 + binPackages = [ pkgs.bcache-tools ]; 21 + }; 22 + }; 13 23 }
+2 -2
nixos/modules/tasks/filesystems/btrfs.nix
··· 66 66 ] 67 67 ); 68 68 69 - boot.initrd.extraUtilsCommands = mkIf inInitrd 69 + boot.initrd.extraUtilsCommands = mkIf (inInitrd && !config.boot.initrd.systemd.enable) 70 70 '' 71 71 copy_bin_and_libs ${pkgs.btrfs-progs}/bin/btrfs 72 72 ln -sv btrfs $out/bin/btrfsck 73 73 ln -sv btrfsck $out/bin/fsck.btrfs 74 74 ''; 75 75 76 - boot.initrd.extraUtilsCommandsTest = mkIf inInitrd 76 + boot.initrd.extraUtilsCommandsTest = mkIf (inInitrd && !config.boot.initrd.systemd.enable) 77 77 '' 78 78 $out/bin/btrfs --version 79 79 '';
+1 -1
nixos/modules/tasks/filesystems/cifs.nix
··· 16 16 boot.initrd.availableKernelModules = mkIf inInitrd 17 17 [ "cifs" "nls_utf8" "hmac" "md4" "ecb" "des_generic" "sha256" ]; 18 18 19 - boot.initrd.extraUtilsCommands = mkIf inInitrd 19 + boot.initrd.extraUtilsCommands = mkIf (inInitrd && !config.boot.initrd.systemd.enable) 20 20 '' 21 21 copy_bin_and_libs ${pkgs.cifs-utils}/sbin/mount.cifs 22 22 '';
+10 -4
nixos/modules/tasks/filesystems/ext.nix
··· 1 - { pkgs, ... }: 1 + { config, lib, pkgs, ... }: 2 + 3 + let 4 + 5 + inInitrd = lib.any (fs: fs == "ext2" || fs == "ext3" || fs == "ext4") config.boot.initrd.supportedFilesystems; 6 + 7 + in 2 8 3 9 { 4 10 config = { 5 11 6 - system.fsPackages = [ pkgs.e2fsprogs ]; 12 + system.fsPackages = lib.mkIf (config.boot.initrd.systemd.enable -> inInitrd) [ pkgs.e2fsprogs ]; 7 13 8 14 # As of kernel 4.3, there is no separate ext3 driver (they're also handled by ext4.ko) 9 - boot.initrd.availableKernelModules = [ "ext2" "ext4" ]; 15 + boot.initrd.availableKernelModules = lib.mkIf (config.boot.initrd.systemd.enable -> inInitrd) [ "ext2" "ext4" ]; 10 16 11 - boot.initrd.extraUtilsCommands = 17 + boot.initrd.extraUtilsCommands = lib.mkIf (!config.boot.initrd.systemd.enable) 12 18 '' 13 19 # Copy e2fsck and friends. 14 20 copy_bin_and_libs ${pkgs.e2fsprogs}/sbin/e2fsck
+1 -1
nixos/modules/tasks/filesystems/f2fs.nix
··· 13 13 14 14 boot.initrd.availableKernelModules = mkIf inInitrd [ "f2fs" "crc32" ]; 15 15 16 - boot.initrd.extraUtilsCommands = mkIf inInitrd '' 16 + boot.initrd.extraUtilsCommands = mkIf (inInitrd && !config.boot.initrd.systemd.enable) '' 17 17 copy_bin_and_libs ${pkgs.f2fs-tools}/sbin/fsck.f2fs 18 18 ${optionalString (any (fs: fs.autoResize) fileSystems) '' 19 19 # We need f2fs-tools' tools to resize filesystems
+1 -1
nixos/modules/tasks/filesystems/jfs.nix
··· 12 12 13 13 boot.initrd.kernelModules = mkIf inInitrd [ "jfs" ]; 14 14 15 - boot.initrd.extraUtilsCommands = mkIf inInitrd '' 15 + boot.initrd.extraUtilsCommands = mkIf (inInitrd && !boot.initrd.systemd.enable) '' 16 16 copy_bin_and_libs ${pkgs.jfsutils}/sbin/fsck.jfs 17 17 ''; 18 18 };
+1 -1
nixos/modules/tasks/filesystems/reiserfs.nix
··· 15 15 16 16 boot.initrd.kernelModules = mkIf inInitrd [ "reiserfs" ]; 17 17 18 - boot.initrd.extraUtilsCommands = mkIf inInitrd 18 + boot.initrd.extraUtilsCommands = mkIf (inInitrd && !config.boot.initrd.systemd.enable) 19 19 '' 20 20 copy_bin_and_libs ${pkgs.reiserfsprogs}/sbin/reiserfsck 21 21 ln -s reiserfsck $out/bin/fsck.reiserfs
+13 -2
nixos/modules/tasks/filesystems/unionfs-fuse.nix
··· 6 6 (lib.mkIf (lib.any (fs: fs == "unionfs-fuse") config.boot.initrd.supportedFilesystems) { 7 7 boot.initrd.kernelModules = [ "fuse" ]; 8 8 9 - boot.initrd.extraUtilsCommands = '' 9 + boot.initrd.extraUtilsCommands = lib.mkIf (!config.boot.initrd.systemd.enable) '' 10 10 copy_bin_and_libs ${pkgs.fuse}/sbin/mount.fuse 11 11 copy_bin_and_libs ${pkgs.unionfs-fuse}/bin/unionfs 12 12 substitute ${pkgs.unionfs-fuse}/sbin/mount.unionfs-fuse $out/bin/mount.unionfs-fuse \ ··· 16 16 chmod +x $out/bin/mount.unionfs-fuse 17 17 ''; 18 18 19 - boot.initrd.postDeviceCommands = '' 19 + boot.initrd.postDeviceCommands = lib.mkIf (!config.boot.initrd.systemd.enable) '' 20 20 # Hacky!!! fuse hard-codes the path to mount 21 21 mkdir -p /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-${pkgs.util-linux.name}-bin/bin 22 22 ln -s $(which mount) /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-${pkgs.util-linux.name}-bin/bin 23 23 ln -s $(which umount) /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-${pkgs.util-linux.name}-bin/bin 24 24 ''; 25 + 26 + boot.initrd.systemd.extraBin = { 27 + "mount.fuse" = "${pkgs.fuse}/bin/mount.fuse"; 28 + "unionfs" = "${pkgs.unionfs-fuse}/bin/unionfs"; 29 + "mount.unionfs-fuse" = pkgs.runCommand "mount.unionfs-fuse" {} '' 30 + substitute ${pkgs.unionfs-fuse}/sbin/mount.unionfs-fuse $out \ 31 + --replace '${pkgs.bash}/bin/bash' /bin/sh \ 32 + --replace '${pkgs.fuse}/sbin' /bin \ 33 + --replace '${pkgs.unionfs-fuse}/bin' /bin 34 + ''; 35 + }; 25 36 }) 26 37 27 38 (lib.mkIf (lib.any (fs: fs == "unionfs-fuse") config.boot.supportedFilesystems) {
+1 -1
nixos/modules/tasks/filesystems/vfat.nix
··· 15 15 16 16 boot.initrd.kernelModules = mkIf inInitrd [ "vfat" "nls_cp437" "nls_iso8859-1" ]; 17 17 18 - boot.initrd.extraUtilsCommands = mkIf inInitrd 18 + boot.initrd.extraUtilsCommands = mkIf (inInitrd && !config.boot.initrd.systemd.enable) 19 19 '' 20 20 copy_bin_and_libs ${pkgs.dosfstools}/sbin/dosfsck 21 21 ln -sv dosfsck $out/bin/fsck.vfat
+2 -2
nixos/modules/tasks/filesystems/xfs.nix
··· 15 15 16 16 boot.initrd.availableKernelModules = mkIf inInitrd [ "xfs" "crc32c" ]; 17 17 18 - boot.initrd.extraUtilsCommands = mkIf inInitrd 18 + boot.initrd.extraUtilsCommands = mkIf (inInitrd && !boot.initrd.systemd.enable) 19 19 '' 20 20 copy_bin_and_libs ${pkgs.xfsprogs.bin}/bin/fsck.xfs 21 21 copy_bin_and_libs ${pkgs.xfsprogs.bin}/bin/xfs_repair 22 22 ''; 23 23 24 24 # Trick just to set 'sh' after the extraUtils nuke-refs. 25 - boot.initrd.extraUtilsCommandsTest = mkIf inInitrd 25 + boot.initrd.extraUtilsCommandsTest = mkIf (inInitrd && !boot.initrd.systemd.enable) 26 26 '' 27 27 sed -i -e 's,^#!.*,#!'$out/bin/sh, $out/bin/fsck.xfs 28 28 '';