From 1e6cf6f3dc967dbf1f20a5a7f3515dcaa316c22d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Thu, 29 Dec 2022 17:35:25 +0100 Subject: [PATCH 1/6] bcachefs-tools: add symlink for mount.bcachefs and fix runtime deps --- pkgs/tools/filesystems/bcachefs-tools/default.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkgs/tools/filesystems/bcachefs-tools/default.nix b/pkgs/tools/filesystems/bcachefs-tools/default.nix index 4e52a1d9e567..a68166c8c275 100644 --- a/pkgs/tools/filesystems/bcachefs-tools/default.nix +++ b/pkgs/tools/filesystems/bcachefs-tools/default.nix @@ -13,9 +13,12 @@ , zstd , lz4 , python3Packages +, util-linux , udev , valgrind , nixosTests +, makeWrapper +, getopt , fuse3 , fuseSupport ? false }: @@ -39,7 +42,9 @@ stdenv.mkDerivation { "INITRAMFS_DIR=${placeholder "out"}/etc/initramfs-tools" ''; - nativeBuildInputs = [ pkg-config docutils python3Packages.python ]; + nativeBuildInputs = [ + pkg-config docutils python3Packages.python makeWrapper + ]; buildInputs = [ libuuid libscrypt libsodium keyutils liburcu zlib libaio @@ -54,6 +59,13 @@ stdenv.mkDerivation { rm tests/test_fuse.py ''; + # this symlink is needed for mount -t bcachefs to work + postFixup = '' + ln -s $out/bin/mount.bcachefs.sh $out/bin/mount.bcachefs + wrapProgram $out/bin/mount.bcachefs.sh \ + --prefix PATH : ${lib.makeBinPath [ getopt util-linux ]} + ''; + installFlags = [ "PREFIX=${placeholder "out"}" ]; passthru.tests = { From 655e07253340c2fcc2dbbd894f12362dc7950800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Thu, 29 Dec 2022 23:17:27 +0100 Subject: [PATCH 2/6] nixos/bcachefs: fix boot with systemd enabled initrd --- nixos/modules/tasks/filesystems/bcachefs.nix | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/nixos/modules/tasks/filesystems/bcachefs.nix b/nixos/modules/tasks/filesystems/bcachefs.nix index ac41ba5f93a4..e3ad52a7b056 100644 --- a/nixos/modules/tasks/filesystems/bcachefs.nix +++ b/nixos/modules/tasks/filesystems/bcachefs.nix @@ -42,7 +42,11 @@ in { config = mkIf (elem "bcachefs" config.boot.supportedFilesystems) (mkMerge [ { - system.fsPackages = [ pkgs.bcachefs-tools ]; + # We do not want to include bachefs in the fsPackages for systemd-initrd + # because we provide the unwrapped version of mount.bcachefs + # through the extraBin option, which will make it available for use. + system.fsPackages = lib.optional (!config.boot.initrd.systemd.enable) pkgs.bcachefs-tools; + environment.systemPackages = lib.optional (config.boot.initrd.systemd.enable) pkgs.bcachefs-tools; # use kernel package with bcachefs support until it's in mainline boot.kernelPackages = pkgs.linuxPackages_testing_bcachefs; @@ -52,7 +56,14 @@ in # chacha20 and poly1305 are required only for decryption attempts boot.initrd.availableKernelModules = [ "bcachefs" "sha256" "chacha20" "poly1305" ]; - boot.initrd.extraUtilsCommands = '' + boot.initrd.systemd.extraBin = { + "bcachefs" = "${pkgs.bcachefs-tools}/bin/bcachefs"; + "mount.bcachefs" = pkgs.runCommand "mount.bcachefs" {} '' + cp -pdv ${pkgs.bcachefs-tools}/bin/.mount.bcachefs.sh-wrapped $out + ''; + }; + + boot.initrd.extraUtilsCommands = lib.mkIf (!config.boot.initrd.systemd.enable) '' copy_bin_and_libs ${pkgs.bcachefs-tools}/bin/bcachefs ''; boot.initrd.extraUtilsCommandsTest = '' From 5d986f42d96981402a1e23d31bbce4f11e9db3c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 1 Jan 2023 19:06:58 +0100 Subject: [PATCH 3/6] bcachefs-tools: unstable-2022-09-28 -> unstable-2022-12-29 Diff: https://github.com/koverstreet/bcachefs-tools/compare/99caca2c70f312c4a2504a7e7a9c92a91426d885...42cf74fd1d0ef58927967e6236988e86cfc0d086 --- pkgs/tools/filesystems/bcachefs-tools/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/tools/filesystems/bcachefs-tools/default.nix b/pkgs/tools/filesystems/bcachefs-tools/default.nix index a68166c8c275..30ffb2dd43f0 100644 --- a/pkgs/tools/filesystems/bcachefs-tools/default.nix +++ b/pkgs/tools/filesystems/bcachefs-tools/default.nix @@ -25,13 +25,13 @@ stdenv.mkDerivation { pname = "bcachefs-tools"; - version = "unstable-2022-09-28"; + version = "unstable-2022-12-29"; src = fetchFromGitHub { owner = "koverstreet"; repo = "bcachefs-tools"; - rev = "99caca2c70f312c4a2504a7e7a9c92a91426d885"; - sha256 = "sha256-9bFTBFkQq8SvhYa9K4+MH2zvKZviNaq0sFWoeGgch7g="; + rev = "42cf74fd1d0ef58927967e6236988e86cfc0d086"; + sha256 = "sha256-N/1heStwmB7CzE/ddTud/ywnMdhq8ZkLju+x0UL0yjY="; }; postPatch = '' From dda48a504471e79b25d65491e1dcbeaf8e5609f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 1 Jan 2023 19:51:23 +0100 Subject: [PATCH 4/6] linux_testing_bcachefs: 2022-10-31 -> 2022-12-29 --- pkgs/os-specific/linux/kernel/linux-testing-bcachefs.nix | 7 ++++--- pkgs/top-level/linux-kernels.nix | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/linux-testing-bcachefs.nix b/pkgs/os-specific/linux/kernel/linux-testing-bcachefs.nix index a80642334f3c..8a6d1a89dc87 100644 --- a/pkgs/os-specific/linux/kernel/linux-testing-bcachefs.nix +++ b/pkgs/os-specific/linux/kernel/linux-testing-bcachefs.nix @@ -1,9 +1,10 @@ { lib , fetchpatch , kernel -, commitDate ? "2022-10-31" -, currentCommit ? "77c27f28aa58e9d9037eb68c87d3283f68c371f7" -, diffHash ? "sha256-TUpI9z0ac3rjn2oT5Z7oQXevDKbGwTVjyigS5/aGwgQ=" +, commitDate ? "2022-12-29" +, currentCommit ? "8f064a4cb5c7cce289b83d7a459e6d8620188b37" +, diffHash ? "sha256-RnlM7uOSWhFHG1aj5BOjrfRtoZfbx+tqQw1V49nW5vw=" + , kernelPatches # must always be defined in bcachefs' all-packages.nix entry because it's also a top-level attribute supplied by callPackage , argsOverride ? {} , ... diff --git a/pkgs/top-level/linux-kernels.nix b/pkgs/top-level/linux-kernels.nix index d6c9bd3ceeae..c8791a4ba005 100644 --- a/pkgs/top-level/linux-kernels.nix +++ b/pkgs/top-level/linux-kernels.nix @@ -184,7 +184,7 @@ in { else testing; linux_testing_bcachefs = callPackage ../os-specific/linux/kernel/linux-testing-bcachefs.nix rec { - kernel = linux_6_0; + kernel = linux_6_1; kernelPatches = kernel.kernelPatches; }; From 13b0e42202fa3919d551e2e130098c2b14e4b745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 1 Jan 2023 19:52:05 +0100 Subject: [PATCH 5/6] nixos/tests/installer: disable zfs for bcachefs tests we are potentially testing very new kernels here, which are not supported by zfs yet. --- nixos/tests/installer.nix | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/nixos/tests/installer.nix b/nixos/tests/installer.nix index 398ad8de19cf..223aac491391 100644 --- a/nixos/tests/installer.nix +++ b/nixos/tests/installer.nix @@ -465,8 +465,12 @@ let ''; testSpecialisationConfig = true; }; - - + # disable zfs so we can support latest kernel if needed + no-zfs-module = { + nixpkgs.overlays = [(final: super: { + zfs = super.zfs.overrideAttrs(_: {meta.platforms = [];});} + )]; + }; in { # !!! `parted mkpart' seems to silently create overlapping partitions. @@ -714,6 +718,7 @@ in { bcachefsSimple = makeInstallerTest "bcachefs-simple" { extraInstallerConfig = { boot.supportedFilesystems = [ "bcachefs" ]; + imports = [ no-zfs-module ]; }; createPartitions = '' @@ -737,6 +742,10 @@ in { bcachefsEncrypted = makeInstallerTest "bcachefs-encrypted" { extraInstallerConfig = { boot.supportedFilesystems = [ "bcachefs" ]; + + # disable zfs so we can support latest kernel if needed + imports = [ no-zfs-module ]; + environment.systemPackages = with pkgs; [ keyutils ]; }; @@ -769,6 +778,9 @@ in { bcachefsMulti = makeInstallerTest "bcachefs-multi" { extraInstallerConfig = { boot.supportedFilesystems = [ "bcachefs" ]; + + # disable zfs so we can support latest kernel if needed + imports = [ no-zfs-module ]; }; createPartitions = '' From c8104628f4057f2b1842f6e31eaff2fe1d0eeda7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 1 Jan 2023 19:53:11 +0100 Subject: [PATCH 6/6] nixos/tests/installer/bcachefs: use ocr to type in password --- nixos/tests/installer.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/nixos/tests/installer.nix b/nixos/tests/installer.nix index 223aac491391..5f3f61632f07 100644 --- a/nixos/tests/installer.nix +++ b/nixos/tests/installer.nix @@ -749,10 +749,15 @@ in { environment.systemPackages = with pkgs; [ keyutils ]; }; - # We don't want to use the normal way of unlocking bcachefs defined in tasks/filesystems/bcachefs.nix. - # So, override initrd.postDeviceCommands completely and simply unlock with the predefined password. extraConfig = '' - boot.initrd.postDeviceCommands = lib.mkForce "echo password | bcachefs unlock /dev/vda3"; + boot.kernelParams = lib.mkAfter [ "console=tty0" ]; + ''; + + enableOCR = true; + preBootCommands = '' + machine.start() + machine.wait_for_text("enter passphrase for ") + machine.send_chars("password\n") ''; createPartitions = ''