]> git.sesse.net Git - bcachefs-tools-debian/blob - flake.nix
flake.nix: add boot stage1 module test, which takes a long time to build
[bcachefs-tools-debian] / flake.nix
1 {
2         description = "Userspace tools for bcachefs";
3
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";
8
9         outputs = { self, nixpkgs, utils, filter, ... }@inputs:
10                 let
11                         # System types to support.
12                         supportedSystems = [ "x86_64-linux" ];
13                 in
14                 {
15                         version = "${builtins.substring 0 8 self.lastModifiedDate}-${self.shortRev or "dirty"}";
16
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 ];
25
26                                 # Add bcachefs to boot and kernel
27                                 boot.initrd.supportedFilesystems = [ "bcachefs" ];
28                                 boot.supportedFilesystems = [ "bcachefs" ];
29                         });
30
31                         nixosConfigurations.netboot-bcachefs = self.systems.netboot-bcachefs "x86_64-linux";
32                         systems.netboot-bcachefs = system: (nixpkgs.lib.nixosSystem { 
33                                         inherit system; modules = [
34                                                 self.nixosModule 
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";
41                                                         
42                                                         # Symlink everything together
43                                                         system.build.netboot = pkgs.symlinkJoin {
44                                                                 name = "netboot";
45                                                                 paths = with config.system.build; [
46                                                                         netbootRamdisk
47                                                                         kernel
48                                                                         netbootIpxeScript
49                                                                 ];
50                                                                 preferLocalBuild = true;
51                                                         };
52                                                 })
53                                         ]; 
54                                 });
55                 }
56                 // utils.lib.eachSystem supportedSystems (system: 
57                 let pkgs = import nixpkgs { 
58                         inherit system; 
59                         overlays = [ self.overlay ]; 
60                 }; 
61                 in rec {
62                         
63                         # A Nixpkgs overlay.
64
65                         # Provide some binary packages for selected system types.
66                         defaultPackage = pkgs.bcachefs.tools;
67                         packages = {
68                                 inherit (pkgs.bcachefs)
69                                         tools
70                                         toolsValgrind
71                                         toolsDebug
72                                         mount
73                                         bch_bindgen
74                                         kernel;
75
76                                 tools-musl = pkgs.pkgsMusl.bcachefs.tools;
77                                 mount-musl = pkgs.pkgsMusl.bcachefs.mount;
78                         };
79
80                         checks = { 
81                                 kernelSrc = packages.kernel.src;
82                                 inherit (packages) 
83                                         mount
84                                         bch_bindgen
85                                         toolsValgrind;
86
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;
90                         };
91
92                         devShell = devShells.tools;
93                         devShells.tools = pkgs.bcachefs.tools.override { inShell = true; };
94                         devShells.mount = pkgs.bcachefs.mount.override { inShell = true; };
95                 });
96 }