]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - flake.nix
add nix flake with checks, overlay, and default package
[bcachefs-tools-debian] / flake.nix
diff --git a/flake.nix b/flake.nix
new file mode 100644 (file)
index 0000000..36dda0e
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,50 @@
+{
+       description = "Userspace tools for bcachefs";
+
+       # Nixpkgs / NixOS version to use.
+       inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
+       inputs.utils.url = "github:numtide/flake-utils";
+       inputs.filter.url = "github:numtide/nix-filter";
+
+       outputs = { self, nixpkgs, utils, filter, ... }@inputs:
+               let
+                       # System types to support.
+                       supportedSystems = [ "x86_64-linux" ];
+               in
+               {
+                       version = "${builtins.substring 0 8 self.lastModifiedDate}-${self.shortRev or "dirty"}";
+
+                       overlay = import ./nix/overlay.nix inputs;
+               }
+               // utils.lib.eachSystem supportedSystems (system: 
+               let pkgs = import nixpkgs { 
+                       inherit system; 
+                       overlays = [ self.overlay ]; 
+               }; 
+               in rec {
+                       
+                       # A Nixpkgs overlay.
+
+                       # Provide some binary packages for selected system types.
+                       defaultPackage = pkgs.bcachefs.tools;
+                       packages = {
+                               inherit (pkgs.bcachefs)
+                                       tools
+                                       toolsValgrind
+                                       toolsDebug
+                                       kernel;
+
+                               musl-tools = pkgs.pkgsMusl.bcachefs.tools;
+                               musl-mount = pkgs.pkgsMusl.bcachefs.mount;
+                       };
+
+                       checks = { 
+                               kernelSrc = packages.kernel.src;
+                               inherit (packages) 
+                                       toolsValgrind;
+                       };
+
+                       devShell = devShells.tools;
+                       devShells.tools = pkgs.bcachefs.tools.override { inShell = true; };
+               });
+}