]> git.sesse.net Git - bcachefs-tools-debian/blob - flake.nix
flake.nix: add nixosModules
[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                 // utils.lib.eachSystem supportedSystems (system: 
32                 let pkgs = import nixpkgs { 
33                         inherit system; 
34                         overlays = [ self.overlay ]; 
35                 }; 
36                 in rec {
37                         
38                         # A Nixpkgs overlay.
39
40                         # Provide some binary packages for selected system types.
41                         defaultPackage = pkgs.bcachefs.tools;
42                         packages = {
43                                 inherit (pkgs.bcachefs)
44                                         tools
45                                         toolsValgrind
46                                         toolsDebug
47                                         mount
48                                         bch_bindgen
49                                         kernel;
50
51                                 tools-musl = pkgs.pkgsMusl.bcachefs.tools;
52                                 mount-musl = pkgs.pkgsMusl.bcachefs.mount;
53                         };
54
55                         checks = { 
56                                 kernelSrc = packages.kernel.src;
57                                 inherit (packages) 
58                                         mount
59                                         bch_bindgen
60                                         toolsValgrind;
61                         };
62
63                         devShell = devShells.tools;
64                         devShells.tools = pkgs.bcachefs.tools.override { inShell = true; };
65                         devShells.mount = pkgs.bcachefs.mount.override { inShell = true; };
66                 });
67 }