1 ## Mirrors: https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/tasks/filesystems/bcachefs.nix
2 ## with changes to use flakes and import mount.bcachefs
3 { config, lib, pkgs, utils, ... }:
9 bootFs = filterAttrs (n: fs: (fs.fsType == "bcachefs") && (utils.fsNeededForBoot fs)) config.fileSystems;
10 cfg = config.filesystems.bcachefs;
14 options.filesystems.bcachefs.packages.tools = lib.mkOption {
15 description = "Which package to use to link in the bcachefs tools package";
16 default = pkgs.bcachefs.tools;
17 type = lib.types.package;
19 options.filesystems.bcachefs.packages.mount = lib.mkOption {
20 description = "Which package to use to link in the bcachefs mount package";
21 default = pkgs.bcachefs.mount;
22 type = lib.types.package;
24 options.filesystems.bcachefs.packages.kernelPackages = lib.mkOption {
25 description = "Which package to use to link in the kernel package to use";
26 default = pkgs.bcachefs.kernelPackages;
27 type = lib.types.attrs;
31 config = mkIf (elem "bcachefs" config.boot.supportedFilesystems) (mkMerge [
33 system.fsPackages = [ cfg.packages.tools cfg.packages.mount ];
35 # use kernel package with bcachefs support until it's in mainline
36 boot.kernelPackages = cfg.packages.kernelPackages;
39 (mkIf ((elem "bcachefs" config.boot.initrd.supportedFilesystems) || (bootFs != {})) {
40 # chacha20 and poly1305 are required only for decryption attempts
41 boot.initrd.availableKernelModules = [ "sha256" "chacha20" "poly1305" ];
42 boot.initrd.kernelModules = [ "bcachefs" ];
44 boot.initrd.extraUtilsCommands = ''
45 copy_bin_and_libs ${cfg.packages.tools}/bin/bcachefs
46 copy_bin_and_libs ${cfg.packages.mount}/bin/mount.bcachefs
48 boot.initrd.extraUtilsCommandsTest = ''
49 $out/bin/bcachefs version
50 $out/bin/mount.bcachefs --version