2 description = "Userspace tools for bcachefs";
4 # Nixpkgs / NixOS version to use.
5 inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
6 inputs.utils.url = "github:numtide/flake-utils";
7 inputs.filter.url = "github:numtide/nix-filter";
9 outputs = { self, nixpkgs, utils, filter, ... }@inputs:
11 # System types to support.
12 supportedSystems = [ "x86_64-linux" ];
15 version = "${builtins.substring 0 8 self.lastModifiedDate}-${self.shortRev or "dirty"}";
17 overlay = import ./nix/overlay.nix inputs;
18 nixosModule = self.nixosModules.bcachefs;
19 nixosModules.bcachefs = import ./rust-src/mount/module.nix;
20 nixosModules.bcachefs-enable-boot = ({config, pkgs, lib, ... }:{
21 # Disable Upstream NixOS Module when this is in use
22 disabledModules = [ "tasks/filesystems/bcachefs.nix" ];
23 # Import needed packages
24 nixpkgs.overlays = [ self.overlay ];
26 # Add bcachefs to boot and kernel
27 boot.initrd.supportedFilesystems = [ "bcachefs" ];
28 boot.supportedFilesystems = [ "bcachefs" ];
31 nixosConfigurations.netboot-bcachefs = self.systems.netboot-bcachefs "x86_64-linux";
32 systems.netboot-bcachefs = system: (nixpkgs.lib.nixosSystem {
33 inherit system; modules = [
35 self.nixosModules.bcachefs-enable-boot
36 ("${nixpkgs}/nixos/modules/installer/netboot/netboot-minimal.nix")
37 ({ lib, pkgs, config, ... }: {
38 # installation disk autologin
39 services.getty.autologinUser = lib.mkForce "root";
40 users.users.root.initialPassword = "toor";
42 # Symlink everything together
43 system.build.netboot = pkgs.symlinkJoin {
45 paths = with config.system.build; [
50 preferLocalBuild = true;
56 // utils.lib.eachSystem supportedSystems (system:
57 let pkgs = import nixpkgs {
59 overlays = [ self.overlay ];
65 # Provide some binary packages for selected system types.
66 defaultPackage = pkgs.bcachefs.tools;
68 inherit (pkgs.bcachefs)
76 tools-musl = pkgs.pkgsMusl.bcachefs.tools;
77 mount-musl = pkgs.pkgsMusl.bcachefs.mount;
81 kernelSrc = packages.kernel.src;
87 # Build and test initrd with bcachefs and bcachefs.mount installed
88 # Disabled Test because it takes a while to build the kernel
89 # bootStage1Module = self.nixosConfigurations.netboot-bcachefs.config.system.build.bootStage1;
92 devShell = devShells.tools;
93 devShells.tools = pkgs.bcachefs.tools.override { inShell = true; };
94 devShells.mount = pkgs.bcachefs.mount.override { inShell = true; };