Merge pull request #267640 from Madouura/pr/bcachefs

authored by

Ryan Lahfa and committed by
GitHub
66a09f19 ab3c49d8

+106 -11
+3
nixos/doc/manual/release-notes/rl-2311.section.md
··· 30 30 31 31 [`sudo-rs`]: https://github.com/memorysafety/sudo-rs/ 32 32 33 + - `linuxPackages_testing_bcachefs` is now soft-deprecated by `linuxPackages_testing`. 34 + - Please consider changing your NixOS configuration's `boot.kernelPackages` to `linuxPackages_testing` until a stable kernel with bcachefs support is released. 35 + 33 36 - All [ROCm](https://rocm.docs.amd.com/en/latest/) packages have been updated to 5.7.0. 34 37 - [ROCm](https://rocm.docs.amd.com/en/latest/) package attribute sets are versioned: `rocmPackages` -> `rocmPackages_5`. 35 38
+31 -10
nixos/modules/tasks/filesystems/bcachefs.nix
··· 1 1 { config, lib, pkgs, utils, ... }: 2 2 3 - with lib; 4 - 5 3 let 6 4 7 - bootFs = filterAttrs (n: fs: (fs.fsType == "bcachefs") && (utils.fsNeededForBoot fs)) config.fileSystems; 5 + bootFs = lib.filterAttrs (n: fs: (fs.fsType == "bcachefs") && (utils.fsNeededForBoot fs)) config.fileSystems; 8 6 9 7 commonFunctions = '' 10 8 prompt() { ··· 56 54 # remove this adaptation when bcachefs implements mounting by filesystem uuid 57 55 # also, implement automatic waiting for the constituent devices when that happens 58 56 # bcachefs does not support mounting devices with colons in the path, ergo we don't (see #49671) 59 - firstDevice = fs: head (splitString ":" fs.device); 57 + firstDevice = fs: lib.head (lib.splitString ":" fs.device); 60 58 61 59 openCommand = name: fs: '' 62 60 tryUnlock ${name} ${firstDevice fs} ··· 90 88 }; 91 89 }; 92 90 91 + assertions = [ 92 + { 93 + assertion = let 94 + kernel = config.boot.kernelPackages.kernel; 95 + in ( 96 + kernel.kernelAtLeast "6.7" || ( 97 + lib.elem (kernel.structuredExtraConfig.BCACHEFS_FS or null) [ 98 + lib.kernel.module 99 + lib.kernel.yes 100 + lib.kernel.option.yes 101 + ] 102 + ) 103 + ); 104 + 105 + message = "Linux 6.7-rc1 at minimum or a custom linux kernel with bcachefs support is required"; 106 + } 107 + ]; 93 108 in 94 109 95 110 { 96 - config = mkIf (elem "bcachefs" config.boot.supportedFilesystems) (mkMerge [ 111 + config = lib.mkIf (lib.elem "bcachefs" config.boot.supportedFilesystems) (lib.mkMerge [ 97 112 { 113 + inherit assertions; 98 114 # needed for systemd-remount-fs 99 115 system.fsPackages = [ pkgs.bcachefs-tools ]; 100 116 101 - # use kernel package with bcachefs support until it's in mainline 102 - # TODO replace with requireKernelConfig 103 - boot.kernelPackages = pkgs.linuxPackages_testing_bcachefs; 117 + # FIXME: Replace this with `linuxPackages_testing` after NixOS 23.11 is released 118 + # FIXME: Replace this with `linuxPackages_latest` when 6.7 is released, remove this line when the LTS version is at least 6.7 119 + boot.kernelPackages = lib.mkDefault ( 120 + # FIXME: Remove warning after NixOS 23.11 is released 121 + lib.warn "Please upgrade to Linux 6.7-rc1 or later: 'linuxPackages_testing_bcachefs' is deprecated. Use 'boot.kernelPackages = pkgs.linuxPackages_testing;' to silence this warning" 122 + pkgs.linuxPackages_testing_bcachefs 123 + ); 104 124 105 125 systemd.services = lib.mapAttrs' (mkUnits "") (lib.filterAttrs (n: fs: (fs.fsType == "bcachefs") && (!utils.fsNeededForBoot fs)) config.fileSystems); 106 126 } 107 127 108 - (mkIf ((elem "bcachefs" config.boot.initrd.supportedFilesystems) || (bootFs != {})) { 128 + (lib.mkIf ((lib.elem "bcachefs" config.boot.initrd.supportedFilesystems) || (bootFs != {})) { 129 + inherit assertions; 109 130 # chacha20 and poly1305 are required only for decryption attempts 110 131 boot.initrd.availableKernelModules = [ "bcachefs" "sha256" "chacha20" "poly1305" ]; 111 132 boot.initrd.systemd.extraBin = { ··· 121 142 $out/bin/bcachefs version 122 143 ''; 123 144 124 - boot.initrd.postDeviceCommands = lib.mkIf (!config.boot.initrd.systemd.enable) (commonFunctions + concatStrings (mapAttrsToList openCommand bootFs)); 145 + boot.initrd.postDeviceCommands = lib.mkIf (!config.boot.initrd.systemd.enable) (commonFunctions + lib.concatStrings (lib.mapAttrsToList openCommand bootFs)); 125 146 126 147 boot.initrd.systemd.services = lib.mapAttrs' (mkUnits "/sysroot") bootFs; 127 148 })
+62
nixos/tests/installer.nix
··· 991 991 ''; 992 992 }; 993 993 994 + bcachefsLinuxTesting = makeInstallerTest "bcachefs-linux-testing" { 995 + extraInstallerConfig = { 996 + imports = [ no-zfs-module ]; 997 + 998 + boot = { 999 + supportedFilesystems = [ "bcachefs" ]; 1000 + kernelPackages = pkgs.linuxPackages_testing; 1001 + }; 1002 + }; 1003 + 1004 + extraConfig = '' 1005 + boot.kernelPackages = pkgs.linuxPackages_testing; 1006 + ''; 1007 + 1008 + createPartitions = '' 1009 + machine.succeed( 1010 + "flock /dev/vda parted --script /dev/vda -- mklabel msdos" 1011 + + " mkpart primary ext2 1M 100MB" # /boot 1012 + + " mkpart primary linux-swap 100M 1024M" # swap 1013 + + " mkpart primary 1024M -1s", # / 1014 + "udevadm settle", 1015 + "mkswap /dev/vda2 -L swap", 1016 + "swapon -L swap", 1017 + "mkfs.bcachefs -L root /dev/vda3", 1018 + "mount -t bcachefs /dev/vda3 /mnt", 1019 + "mkfs.ext3 -L boot /dev/vda1", 1020 + "mkdir -p /mnt/boot", 1021 + "mount /dev/vda1 /mnt/boot", 1022 + ) 1023 + ''; 1024 + }; 1025 + 1026 + bcachefsUpgradeToLinuxTesting = makeInstallerTest "bcachefs-upgrade-to-linux-testing" { 1027 + extraInstallerConfig = { 1028 + imports = [ no-zfs-module ]; 1029 + boot.supportedFilesystems = [ "bcachefs" ]; 1030 + # We don't have network access in the VM, we need this for `nixos-install` 1031 + system.extraDependencies = [ pkgs.linux_testing ]; 1032 + }; 1033 + 1034 + extraConfig = '' 1035 + boot.kernelPackages = pkgs.linuxPackages_testing; 1036 + ''; 1037 + 1038 + createPartitions = '' 1039 + machine.succeed( 1040 + "flock /dev/vda parted --script /dev/vda -- mklabel msdos" 1041 + + " mkpart primary ext2 1M 100MB" # /boot 1042 + + " mkpart primary linux-swap 100M 1024M" # swap 1043 + + " mkpart primary 1024M -1s", # / 1044 + "udevadm settle", 1045 + "mkswap /dev/vda2 -L swap", 1046 + "swapon -L swap", 1047 + "mkfs.bcachefs -L root /dev/vda3", 1048 + "mount -t bcachefs /dev/vda3 /mnt", 1049 + "mkfs.ext3 -L boot /dev/vda1", 1050 + "mkdir -p /mnt/boot", 1051 + "mount /dev/vda1 /mnt/boot", 1052 + ) 1053 + ''; 1054 + }; 1055 + 994 1056 # Test using labels to identify volumes in grub 995 1057 simpleLabels = makeInstallerTest "simpleLabels" { 996 1058 createPartitions = ''
+7 -1
pkgs/tools/filesystems/bcachefs-tools/default.nix
··· 81 81 passthru = { 82 82 tests = { 83 83 smoke-test = nixosTests.bcachefs; 84 - inherit (nixosTests.installer) bcachefsSimple bcachefsEncrypted bcachefsMulti; 84 + 85 + inherit (nixosTests.installer) 86 + bcachefsSimple 87 + bcachefsEncrypted 88 + bcachefsMulti 89 + bcachefsLinuxTesting 90 + bcachefsUpgradeToLinuxTesting; 85 91 }; 86 92 87 93 updateScript = writeScript "update-bcachefs-tools-and-cargo-lock.sh" ''
+1
pkgs/top-level/all-packages.nix
··· 28106 28106 linuxPackages_testing = linuxKernel.packages.linux_testing; 28107 28107 linux_testing = linuxKernel.kernels.linux_testing; 28108 28108 28109 + # FIXME: Remove and alias to `linux(Packages)_testing`` after 23.11 is released 28109 28110 linuxPackages_testing_bcachefs = linuxKernel.packages.linux_testing_bcachefs; 28110 28111 linux_testing_bcachefs = linuxKernel.kernels.linux_testing_bcachefs; 28111 28112
+2
pkgs/top-level/linux-kernels.nix
··· 201 201 then latest 202 202 else testing; 203 203 204 + # FIXME: Remove after 23.11 is released 204 205 linux_testing_bcachefs = callPackage ../os-specific/linux/kernel/linux-testing-bcachefs.nix { 205 206 # Pinned on the last version which Kent's commits can be cleany rebased up. 206 207 kernel = linux_6_5; ··· 612 613 613 614 # Intentionally lacks recurseIntoAttrs, as -rc kernels will quite likely break out-of-tree modules and cause failed Hydra builds. 614 615 linux_testing = packagesFor kernels.linux_testing; 616 + # FIXME: Remove after 23.11 is released 615 617 linux_testing_bcachefs = recurseIntoAttrs (packagesFor kernels.linux_testing_bcachefs); 616 618 617 619 linux_hardened = recurseIntoAttrs (packagesFor kernels.linux_hardened);