From eca7cb9132e749092230a9d5ef4306bea039a6d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Thu, 29 Dec 2022 18:46:31 +0100 Subject: [PATCH] bcachefs support --- example/bcachefs.nix | 39 +++++++++++++++++++++++++++++++++++++++ flake.lock | 6 +++--- tests/bcachefs.nix | 18 ++++++++++++++++++ types.nix | 1 + 4 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 example/bcachefs.nix create mode 100644 tests/bcachefs.nix diff --git a/example/bcachefs.nix b/example/bcachefs.nix new file mode 100644 index 0000000..a98c42a --- /dev/null +++ b/example/bcachefs.nix @@ -0,0 +1,39 @@ +{ disks ? [ "/dev/vdb" ], ... }: { + disk = { + vdb = { + device = builtins.elemAt disks 0; + type = "disk"; + content = { + type = "table"; + format = "gpt"; + partitions = [ + { + type = "partition"; + name = "ESP"; + start = "1MiB"; + end = "100MiB"; + bootable = true; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + } + { + name = "root"; + type = "partition"; + start = "100MiB"; + end = "100%"; + part-type = "primary"; + content = { + type = "filesystem"; + format = "bcachefs"; + mountpoint = "/"; + }; + } + ]; + }; + }; + }; +} + diff --git a/flake.lock b/flake.lock index 45dc98e..12d9acf 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1671788672, - "narHash": "sha256-tLkPxJuos3jki2f/TZdHn+NuMQAzN9s2E4QudylQLg0=", + "lastModified": 1672756850, + "narHash": "sha256-Smbq3+fitwA13qsTMeaaurv09/KVbZfW7m7lINwzDGA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2c74fcd6c5fc14a61de158fb796243543f46b217", + "rev": "298add347c2bbce14020fcb54051f517c391196b", "type": "github" }, "original": { diff --git a/tests/bcachefs.nix b/tests/bcachefs.nix new file mode 100644 index 0000000..58ca8d3 --- /dev/null +++ b/tests/bcachefs.nix @@ -0,0 +1,18 @@ +{ pkgs ? (import { }) +, makeDiskoTest ? (pkgs.callPackage ./lib.nix { }).makeDiskoTest +}: +makeDiskoTest { + disko-config = ../example/bcachefs.nix; + extraTestScript = '' + machine.succeed("mountpoint /"); + machine.succeed("lsblk >&2"); + ''; + # so that the installer boots with a bcachefs enabled kernel + extraConfig = { + boot.supportedFilesystems = [ "bcachefs" ]; + # disable zfs so we can support latest kernel + nixpkgs.overlays = [(final: super: { + zfs = super.zfs.overrideAttrs(_: {meta.platforms = [];});} + )]; + }; +} diff --git a/types.nix b/types.nix index 54b280e..c41f09e 100644 --- a/types.nix +++ b/types.nix @@ -545,6 +545,7 @@ rec { else if (config.format == "ext2") then [ pkgs.e2fsprogs ] else if (config.format == "ext3") then [ pkgs.e2fsprogs ] else if (config.format == "ext4") then [ pkgs.e2fsprogs ] + else if (config.format == "bcachefs") then [ pkgs.bcachefs-tools ] else [] ); };